Boost a record by point assigned to that record in Elastic Search Boost a record by point assigned to that record in Elastic Search elasticsearch elasticsearch

Boost a record by point assigned to that record in Elastic Search


I solved this using the following:

custom_score :script => "_score+doc['increase_relevance_points'].value" do  boolean do    should { match :increase_relevance_text, term}  endend


You can index the point value from the database record into ElasticSearch as an integer. Once it's there you have lots of options using custom_score or script based sorting.

If you want to boost each result by a factor of the point_value then the query might look something like:

"query": {    "custom_score" : {        "query" : {            ....        },        "script" : "doc['point_value'].value * _score"    }}

Check out the custom score query docs for full info.