Jonas F. Henriksen 3d5238bd95 Make it clear this is boost at index time (#51390)
The way it was originally written, it sounds like 
we are boosting at query time.
 Of course, the effect is at query time, 
but the point here is that boosting is done at index time
2020-01-24 10:37:07 -05:00

81 lines
2.3 KiB
Plaintext

[[mapping-boost]]
=== `boost`
Individual fields can be _boosted_ automatically at index time (to count more towards the relevance score), with the `boost` parameter as follows:
[source,console]
--------------------------------------------------
PUT my_index
{
"mappings": {
"properties": {
"title": {
"type": "text",
"boost": 2 <1>
},
"content": {
"type": "text"
}
}
}
}
--------------------------------------------------
<1> Matches on the `title` field will have twice the weight as those on the
`content` field, which has the default `boost` of `1.0`.
NOTE: 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):
[source,console]
--------------------------------------------------
POST _search
{
"query": {
"match" : {
"title": {
"query": "quick brown fox"
}
}
}
}
--------------------------------------------------
is equivalent to:
[source,console]
--------------------------------------------------
POST _search
{
"query": {
"match" : {
"title": {
"query": "quick brown fox",
"boost": 2
}
}
}
}
--------------------------------------------------
deprecated[5.0.0, "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."]
[WARNING]
.Why index time boosting is a bad idea
==================================================
We advise against using index time boosting for the following reasons:
* You cannot change index-time `boost` values without reindexing all of your
documents.
* Every query supports query-time boosting which achieves the same effect. The
difference is that you can tweak the `boost` value without having to reindex.
* Index-time boosts are stored as part of the <<norms,`norm`>>, which is only one
byte. This reduces the resolution of the field length normalization factor
which can lead to lower quality relevance calculations.
==================================================