0

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!

Kathan
  • 1,428
  • 2
  • 15
  • 31

2 Answers2

3

Try this .....

Model.search "hi@example.com", fields: [{column_name1: :exact}, :column_name2]

Hope this will help you.

Akshay Borade
  • 2,442
  • 12
  • 26
1

I had a similar issue. I solved it like this.

Model.search(
    'search term',
    fields: [
        {'name^2' => :phrase},
        {'name' => :word_start},
    ]
)
tdxius
  • 281
  • 3
  • 11