Boost Custom Sort According to Query

(davrob) #1


My queries consist of multiple queries:

i) A Text Prefix Query on fields (firstname, lastname)
ii) A StringQuery on field (companyname)

I would like to have:

1.   all results from i) before the results from ii).
2.   query i) sorted by one field (person_name) and results from

query ii) sorted by another (company__name)

The only way I can think of doing this is firstly to identify which
query a result comes from and apply a custom sort to acheive the above

i.e sort results from i) by person_name and then multiple all results
scores from i) by 1,000,000
sort results from ii) by companyName and then divide all results
scores from ii) by 1,000,000

Is there any way I can identify which query a result has come from in
the custom sort?

Ideally I would apply sorts at the query (QueryBuilder) level and then
apply a boost (i.e. 1,000,000) using CustomBoostFactorQueryBuilder but
it is not possible to sort on QueryBuilder instances only on
SearchRequestBuilder, as far as I can tell, if anyone know of a way of
doing that then that would be even better.

Best Regards,


(system) #2