1

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

1
  • Can you provide your mapping for that index? Commented Oct 29, 2014 at 8:35

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.