Reputation: 954
I have a problem with integrating searchkick and elasticsearch. Here is what I have as of now:
Product records:
id: 1
title: "Electric Fan"
id: 2
title: "Stove"
id: 3
title: "Stoven"
id: 4
title: "Stovener"
Here is my model
class Product < ActiveRecord::Base
searchkick
end
But when I go to the rails console and try to search it only gives me one result:
results = Product.search("Stove")
results.map(&:title) # prints ["Stove"]
I don't know why it is only generating one results which in fact it should generate three. I installed and made sure that elasticsearch is running.
Is there anything that I missed with this one?
TIA
Upvotes: 1
Views: 873
Reputation: 145
Read the documentation:
By default, results must match the entire word - back will not match backpack. You can change this behavior with:
class Product < ActiveRecord::Base
searchkick word_start: [:name]
end
And to search (after you reindex):
Product.search "back", fields: [{name: :word_start}]
SOURCE - https://github.com/ankane/searchkick#partial-matches
Upvotes: 2