-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct boost calculation in script_score query (#52478)
Before boost in script_score query was wrongly applied only to the subquery. This commit makes sure that the boost is applied to the whole score that comes out of script. Closes #48465
- Loading branch information
1 parent
841d961
commit 556ee9a
Showing
3 changed files
with
119 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...s/lang-painless/src/test/resources/rest-api-spec/test/painless/110_script_score_boost.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Integration tests for ScriptScoreQuery using Painless | ||
setup: | ||
- skip: | ||
version: " - 7.9.99" | ||
reason: "boost was corrected in script_score query from 8.0" | ||
- do: | ||
indices.create: | ||
index: test_index | ||
body: | ||
settings: | ||
index: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
k: | ||
type: keyword | ||
i: | ||
type: integer | ||
|
||
- do: | ||
bulk: | ||
index: test_index | ||
refresh: true | ||
body: | ||
- '{"index": {"_id": "1"}}' | ||
- '{"k": "k", "i" : 1}' | ||
- '{"index": {"_id": "2"}}' | ||
- '{"k": "kk", "i" : 2}' | ||
- '{"index": {"_id": "3"}}' | ||
- '{"k": "kkk", "i" : 3}' | ||
--- | ||
"Boost script_score": | ||
- do: | ||
search: | ||
index: test_index | ||
body: | ||
query: | ||
script_score: | ||
query: {match_all: {}} | ||
script: | ||
source: "doc['i'].value * _score" | ||
boost: 10 | ||
|
||
- match: { hits.total.value: 3 } | ||
- match: { hits.hits.0._score: 30 } | ||
- match: { hits.hits.1._score: 20 } | ||
- match: { hits.hits.2._score: 10 } | ||
|
||
--- | ||
"Boost script_score and boost internal query": | ||
- do: | ||
search: | ||
index: test_index | ||
body: | ||
query: | ||
script_score: | ||
query: {match_all: {boost: 5}} | ||
script: | ||
source: "doc['i'].value * _score" | ||
boost: 10 | ||
|
||
- match: { hits.total.value: 3 } | ||
- match: { hits.hits.0._score: 150 } | ||
- match: { hits.hits.1._score: 100 } | ||
- match: { hits.hits.2._score: 50 } | ||
|
||
--- | ||
"Boost script_score with explain": | ||
- do: | ||
search: | ||
index: test_index | ||
body: | ||
explain: true | ||
query: | ||
script_score: | ||
query: {term: {"k": "kkk"}} | ||
script: | ||
source: "doc['i'].value" | ||
boost: 10 | ||
|
||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._score: 30 } | ||
- match: { hits.hits.0._explanation.value: 30 } | ||
- match: { hits.hits.0._explanation.details.0.description: "boost" } | ||
- match: { hits.hits.0._explanation.details.0.value: 10} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters