Search code examples
ruby-on-railsrubyruby-on-rails-4elasticsearchsearchkick

Boost exact match searchkick / elastic search Rails 4


Having trouble getting exact matches to display first. I am using searchkick with elastic search on my rails 4 app.

For example, if a user searches "coke" .. "coke zero" will display first. I would like it the other way around.

If there is documentation on this can you please point me in that way? I am having an overly hard time finding a solution.

I have tried boosting the title field ('specific' in my case):

fields: ["specific^20"]

and boosting where the field matches the query exactly (although I don't know if i'm implementing this correctly):

boost_where: [:specific == :q]

Nothing seems to be working. Thank you!


Solution

  • Try this .....

    Model.search "[email protected]", fields: [{column_name1: :exact}, :column_name2]
    

    Hope this will help you.