Boosting specific documents in every search

You could wrap your query in a function_score query. This query allows you to provide a filter. Any document that matches the filter (in addition to your original query) will get their score modified according to a boost_mode and a weight. By setting boost_mode to multiply and weight to 100, those documents matching the filter will get their score multiplied by 100. Like this:

GET _search
{
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "must": [
            {
              "bool": {
                "should": [
                  {
                    "multi_match": {
                      "type": "best_fields",
                      "query": "exampleKeyword",
                      "fields": [
                        "exampleField1^0",
                        "exampleField2^50",
                        "exampleField3^10",
                        "exampleField4^10",
                        "exampleField5^5"
                      ],
                      "boost": 50
                    }
                  }
                ]
              }
            }
          ]
        }
      },
      "functions": [
        {
          "filter": {
            "terms": {
              "Field6": [
                1,
                2,
                3,
                42
              ]
            }
          },
          "weight": 100
        }
      ],
      "boost_mode": "multiply"
    }
  }
}
1 Like