Reputation: 41
I have run into a problem while trying to make a search with sunspot solr on a Rails 3 app... Currently I search normally for a lot of fields successfully (with and without fulltext), and I need to include a filter so that a possible match gets excluded from the result set if a condition is met:
Example: Search for "BBXY", this search may produce matches like "BBXY01", "XYB03", etc.. and I need to exclude all possible matches that end with "6", is this possible??
Thanks!!
Upvotes: 2
Views: 321
Reputation: 41
I just had a case of "ask on SO and get the answer yourself the next day"
first I configured a field that gets only the last character of the string
string :last_char do
profile.my_string.last
end
and then on the search method used the "without" syntax, like:
User.search do
...
without :last_char, params[:last_char] unless params[:last_char].blank?
end
Hopefully someone will find this useful later :)
Upvotes: 2