Using searchkick and see that a search for "animals"
is returning results for "anime"
because of their stem "anim"
. Does anyone have any suggestions on how to improve these results?
I see the in docs you can do something like
exclude_queries = {
"animals" => ["anime"],
}
Product.search query, exclude: exclude_queries[query]
But it seems like a lot of work to keep a running list for all of the bad ones like this.
Wondering if I need to change the stemmer?
I might try something like this. https://www.elastic.co/guide/en/elasticsearch/reference/master/mixing-exact-search-with-stemming.html
Update
Ankane at searchkick gem was kind enough to add a feature to help with this. As of 4.4.1 you can do this.
class Product < ApplicationRecord
searchkick stemmer_override: ["anime => anime"]
end
This will prevent "anime"
from being stemmed to "anim"
. So it won't show up in the "animals"
search results.