Skip to content

Commit 3ab73ab

Browse files
Deprecate document _boost
Fixes elastic#4664
1 parent 13c88da commit 3ab73ab

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/reference/mapping/fields/boost-field.asciidoc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[[mapping-boost-field]]
22
=== `_boost`
33

4+
deprecated[1.0.0.RC1,See <<function-score-instead-of-boost>>]
5+
46
Boosting is the process of enhancing the relevancy of a document or
57
field. Field level mapping allows to define explicit boost level on a
68
specific field. The boost field mapping (applied on the
@@ -30,3 +32,41 @@ following JSON document will be indexed with a boost value of `2.2`:
3032
"message" : "This is a tweet!"
3133
}
3234
--------------------------------------------------
35+
36+
[[function-score-instead-of-boost]]
37+
==== Function score instead of boost
38+
39+
Support for document boosting via the `_boost` field has been removed
40+
from Lucene and is deprecated in Elasticsearch as of v1.0.0.RC1. The
41+
implementation in Lucene resulted in unpredictable result when
42+
used with multiple fields or multi-value fields.
43+
44+
Instead, the <<query-dsl-function-score-query>> can be used to achieve
45+
the desired functionality by boosting each document by the value in
46+
any field the document:
47+
48+
[source,js]
49+
--------------------------------------------------
50+
{
51+
"query": {
52+
"function_score": {
53+
"query": { <1>
54+
"match": {
55+
"title": "your main query"
56+
}
57+
},
58+
"functions": [{
59+
"script_score": { <2>
60+
"script": "doc['my_boost_field'].value"
61+
}
62+
}],
63+
"score_mode": "multiply"
64+
}
65+
}
66+
}
67+
--------------------------------------------------
68+
<1> The original query, now wrapped in a `function_score` query.
69+
<2> This script returns the value in `my_boost_field`, which is then
70+
multiplied by the query `_score` for each document.
71+
72+

0 commit comments

Comments
 (0)