Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/127229.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 127229
summary: Return BAD_REQUEST when a field scorer references a missing field
area: Ranking
type: bug
issues:
- 127162
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ setup:
- match: { hits.hits.1._score: 20 }
- match: { hits.hits.2._score: 10 }

---
"referencing a missing field returns bad request":
- do:
catch: bad_request
search:
index: test
body:
rescore:
example:
factor: 1
factor_field: missing
- match: { status: 400 }
- match: { error.root_cause.0.type: "illegal_argument_exception" }
- match: { error.root_cause.0.reason: "Missing value for field [missing]" }

---
"sorted based on a numeric field and rescored based on a factor field using a window size":
- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.Explanation;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
Expand Down Expand Up @@ -73,7 +72,7 @@ public double score(int docId, float subQueryScore) throws IOException {
if (missing != null) {
value = missing;
} else {
throw new ElasticsearchException("Missing value for field [" + field + "]");
throw new IllegalArgumentException("Missing value for field [" + field + "]");
}
}
double val = value * boostFactor;
Expand Down
Loading