Elasticsearch - boost nested query with higher value Elasticsearch - boost nested query with higher value elasticsearch elasticsearch

Elasticsearch - boost nested query with higher value


I suggest using function_score to do this and more specifically the field_value_factor function which allows to use a field value in the scoring computation (with an optional factor by which to multiply the field value):

{  "query": {    "filtered": {      "query": {        "bool": {          "must": [            {              "term": {                "is_active": true              }            }          ],          "should": [            {              "nested": {                "path": "skills",                "query": {                  "function_score": {                    "query": {                      "bool": {                        "must": [                          {                            "range": {                              "skills.value": {                                "gte": "2"                              }                            }                          },                          {                            "term": {                              "skills.skill.name": "php"                            }                          }                        ]                      }                    },                    "functions": [                      {                        "field_value_factor": {                          "field": "skills.value",                          "factor": 2                        }                      }                    ]                  }                }              }            }          ]        }      }    }  }}