0

I can send boost value with query like

{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "title": {
              "query": "quick brown fox",
              "boost": 2 
            }
          }
        }
      ]
    }
  }
}

but I can also set boost value in mapping

{
  "properties": {
    "title": {
      "type": "string",
      "boost": 2
    },
    "tags": {
      "type": "string"
    }
  }
}

And my question is. Which of this is faster while executing queries, to have boost in mapping or setting boost in query, or is it equaly fast.

m.s.
  • 16,063
  • 7
  • 53
  • 88
kskaradzinski
  • 4,954
  • 10
  • 48
  • 70
  • 1
    As it relies on lucene you can check the analogous question for solr => [Solr Index time boosting VS Query time boosting?](http://stackoverflow.com/questions/10529127/solr-index-time-boosting-vs-query-time-boosting). – moliware Jul 24 '15 at 13:39

1 Answers1

1

Index-time boosting is unrecommended by Elastic itself for multiple reasons :

  • Combining the boost with the field-length norm and storing it in a single byte means that the field-length norm loses precision. The result is that Elasticsearch is unable to distinguish between a field containing three words and a field containing five words.
  • To change an index-time boost, you have to reindex all your documents. A query-time boost, on the other hand, can be changed with every query.
  • If a field with an index-time boost has multiple values, the boost is multiplied by itself for every value, dramatically increasing the weight for that field.

See https://www.elastic.co/guide/en/elasticsearch/guide/current/practical-scoring-function.html for more details.

As for speed, I don't think it changes much at all, so you should probably stick to Query-time boosting which is the norm.