Diego
Diego

Reputation: 858

How to match incomplete terms in Elasticsearch using Searchkick?

I'm using Elasticsearch + Searchkick in my Rails app to index articles. When I search using incomplete words, it does not work. For example:

Article.search('feature compatibility').pluck(:name)
# => ["Feature compatibility by mobile device"]

Article.search('feature compatibil').pluck(:name)
# => []

My model uses the default Searchkick settings.

Upvotes: 0

Views: 777

Answers (1)

Val
Val

Reputation: 217314

First add this to your model (word_start not text_start)

searchkick word_start: [:name, :body]

Then you need to delete the index, recreate it and reindex your data. After that your search queries will work as expected

Upvotes: 1

Related Questions