Finding sunspots solr in several terms

I am using the sunspot_rails stone and I am trying to search, for example:

search for users where name is Mary or Sally

But I can’t figure out how to do this. If I do something like:

search = Users.search do fulltext 'Mary Sally' end 

or

 search = Users.search do fulltext 'Mary' fulltext 'Sally' end 

I do not get results ... but if I do one, and not both, I get the expected results:

 search = Users.search do fulltext 'Mary' #or fulltext 'Sally' end 

will return one item.

Is this possible with a sunspot?

------- Decision -------

 search = Users.search do fulltext 'Mary Sally' do minimum_match 1 end end 
+6
source share
1 answer

Add minimum_match 1 to your search box, because the default parameter should match all words, so Mary Sally search will only return records with these names.

+11
source

Source: https://habr.com/ru/post/955315/


All Articles