2
votes

I have a Sunspot/SOLR implementation with some text fields that I want to search for "Term A" or "Term B". I can't figure out how to do this.

s = Product.search do
  any_of do
    fulltext "Term A"
    fulltext "Term B"
  end
end

Does not work (all records are returned).

I don't see how this would work directly in SOLR nor do I see how it could work via Sunspot.

1

1 Answers

3
votes

Yes, it doesn't work. But you could use logically expression instead.

Like "AND" "OR" "+" "-" ... etc.

In you case, try

s = Product.search do
  fulltext "Term A OR Term B"
end

It's works to me.