Skip to content

Commit

Permalink
script_score query errors on negative scores
Browse files Browse the repository at this point in the history
7.5 and 7.6 had a regression that allowed for
script_score queries to have negative scores.
We have corrected this regression in elastic#52478.
This is an addition to elastic#52478 that adds
a test and release notes.
  • Loading branch information
mayya-sharipova committed Mar 4, 2020
1 parent 302980e commit 557f5be
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/reference/release-notes/7.7.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ Mapping::
* Dynamic mappings in indices created on 8.0 and later have stricter validation at mapping update time and
results in a deprecation warning for indices created in Elasticsearch 7.7.0 and later.
(e.g. incorrect analyzer settings or unknown field types). {pull}51233[#51233]

Search::
* A regression that allowed negative scores in a script_score query was corrected.
A behaviour is restored that throws an error if script_score query produces
a negative score {pull}52478[#52478].
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Integration tests for ScriptScoreQuery using Painless
setup:
- skip:
version: " - 7.6.99"
reason: "script_score negative score was not allowed again from 7.7"
- do:
indices.create:
index: test_index
body:
settings:
index:
number_of_shards: 1
number_of_replicas: 0
mappings:
properties:
k:
type: keyword

- do:
index:
index: test_index
id: 1
body: { "k": "value" }
refresh: true

---
"script_score should error on negative score":
- do:
catch: /.*script_score script returned an invalid score \[-1000.0\] for doc \[0\].*/
search:
index: test_index
body:
query:
script_score:
query: {match_all: {}}
script:
source: "-1000"

0 comments on commit 557f5be

Please sign in to comment.