Individual fields can be boosted automatically — count more towards the relevance score — at query time, with the boost
parameter as follows:
PUT my_index { "mappings": { "properties": { "title": { "type": "text", "boost": 2 }, "content": { "type": "text" } } } }
Matches on the |
The boost is applied only for term queries (prefix, range and fuzzy queries are not boosted).
You can achieve the same effect by using the boost parameter directly in the query, for instance the following query (with field time boost):
POST _search { "query": { "match" : { "title": { "query": "quick brown fox" } } } }
is equivalent to:
POST _search { "query": { "match" : { "title": { "query": "quick brown fox", "boost": 2 } } } }
"Index time boost is deprecated. Instead, the field mapping boost is applied at query time. For indices created before 5.0.0, the boost will still be applied at index time."
We advise against using index time boosting for the following reasons:
boost
values without reindexing all of your
documents.
boost
value without having to reindex.
norm
, which is only one
byte. This reduces the resolution of the field length normalization factor
which can lead to lower quality relevance calculations.