Priority fetching in terms query


(Jiten Savla) #1

We have a situation where we need to fetch multiple values using terms query say get all the persons have countries 'United States', 'Canada', 'India', 'Brazil' were we need the records in priority. We need to get all records from 'Brazil' first followed by 'United States' followed by 'India' and then 'Canada'.

Is there a way to specify priority in terms query? From what understand terms query returns an assorted records.


(Mark Walkom) #2

You might be able to do something like this with boosting - https://www.elastic.co/guide/en/elasticsearch/reference/2.1/index-boost.html - but I don't think it'll 100% work.


(Jiten Savla) #3

Index time boost doesn't work as the priority is only known at the run time. Any other thoughts?


(Mark Walkom) #4

Ahh, I meant to link to https://www.elastic.co/guide/en/elasticsearch/reference/2.1/query-dsl-query-string-query.html#_boosting


(system) #5