mercredi 17 juin 2015

ElasticSearch / Searchkick - LIKE query

I'm using ElasticSearch gem Searchkick with Rails and I want to perform a search based on 2 values:

- params[:full_text_query]
- params[:only_from_this_location]

One should search full-text on all fields and another should restrict the search only to records that partially match one field.

I want something like this:

Post.search(params[:full_text_query], where: { location: params[:only_from_this_location] })

However I need location filter to match not only exact values, but also partial ones. So not only "New York", but also "New York, US". Like %something% you would do in SQL.

I also need support for pagination so it needs to be in one query.

What are my options?

Aucun commentaire:

Enregistrer un commentaire