Query string with boost fields in Elastic Search Query string with boost fields in Elastic Search elasticsearch elasticsearch

Query string with boost fields in Elastic Search


The boost is only used when the query matches the field you are boosting and it multiplies the score elastic search computes with the boosting you defined. In your query you are looking for "account and data" and that doesn't match any year so the boosting in the year will not be used.

Are you trying to take the year into account for ordering? If that is the case you can try adding the field_value_factor to your query like this:

"query" : {    "function_score": {        "query": { <your query goes here> },        "field_value_factor": {            "field": "year"         }    }}

This will multiply the year with the score elastic search computes so it will take the year into account without necessary ordering by the year. You can read more about it here https://www.elastic.co/guide/en/elasticsearch/guide/current/boosting-by-popularity.html.

You can always use the explain tool to figure out how elastic search came up with the score and thus returned the results in that order. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html