Home > Software engineering >  Elasticsearch - Impact of adding Boost to query
Elasticsearch - Impact of adding Boost to query

Time:04-03

I have a very simple Elastic query mentioned below.

{
  "query": {
    "bool": {
      "must": [
        {
          "bool": {
            "minimum_should_match": 1,
            "should": [
              {
                "match": {
                  "tag": {
                    "query": "Audience: PRO Brand: Samsung",
                    "boost": 3,
                    "operator": "and"
                  }
                }
              },
              {
                "match": {
                  "tag": {
                    "query": "audience: PRO brand samsung",
                    "boost": 2,
                    "operator": "or"
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

I want to know if I add a boost in the query, will there be any performance impact because of this, and also will boosting help if you have a very large data set, where the occurrence of a search word is common.

CodePudding user response:

Elasticsearch adds boost param with default value, IMO giving different value won't make much difference in the performance, but you should be able to measure it yourself.

Reg. your second question, adding boost definitely makes sense where the occurrence of your search words are common, this will help you to find the relevant document. for example: suppose you are searching for query in a index containing Elasticsearch posts(query will be very common on Elasticsearch posts), but you want the give more weight to documents which have tag elasticsearch-query. Adding boosts in this case, will provide you more relevant results.

  • Related