How to boost most popular (top quartile) in elasticsearch query results (outliers)

887 views Asked by At

I have an elasticsearch query that includes bool - must / should sections that I have refined to match search terms and boost for terms in priority fields, phrase match, etc.

I would like to boost documents that are the most popular. The documents include a field "popularity" that indicates the number of times the document was viewed.

Preferably, I would like to boost any documents in the result set that are outliers - meaning that the popularity score is perhaps 2 standard deviations from the average in the result set.

I see aggregations but I'm interested in boosting results in a query, not a report/dashboard.

I also noted the new rank_feature query in ES 7 (I am still on 6.8 but could upgrade). It looks like the rank_feature query looks across all documents, not the result set.

Is there a way to do this?

1

There are 1 answers

1
Jaycreation On

I think that you want to use a rank or a range query in a "rescore query". If your need is to specific for classical queries, you can use a "function_score" query in your rescore and use a script to write your own score calculation

https://www.elastic.co/guide/en/elasticsearch/reference/7.9/filter-search-results.html

https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-rescore.html