Pseudo-Hippy
Pseudo-Hippy

Reputation: 197

Is there a way to exclude words from a query in Searchkick?

I would like to exlude some terms a user may enter into the search bar as they bloat the results.

For separate reasons I need the operator: :or, but if I have a search term like "The Beatles" it searches the whole database for "The" and "Beatles" which is way too many results. I would like to exclude "the" from any query received, so it would be as if the user had only searched "Beatles".

Maybe this isn't possilbe. Thanks for the help 🙏

I tried to add exclude: ["the"], but this removed any ressults which had the term "the".

Upvotes: 0

Views: 329

Answers (2)

Alex Baidan
Alex Baidan

Reputation: 1075

Elasticsearch have great solution fro solving such questions - analyzers.

In your case you need to implement Stop analyser in your mapping. Details and docs can be found here: Stop Analyzer

Upvotes: 0

Shah
Shah

Reputation: 59

Did you tried it:

"The Beatles".gsub('The ', '')

Upvotes: 1

Related Questions