简体   繁体   中英

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!

Try this .....

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

Hope this will help you.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM