apache / apache/lucene

ConstantScoreQuery looses explain details of wrapped query [LUCENE-8606]

Open
#9,652 12 comments 0 reactions 0 assignees View on GitHub
legacy-jira-priority:Major type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

Right now the ConstantScoreWeigth used by the ConstantScoreQuery is not adding the details of the wrapped query to the explanation.

```Java
if (exists) {
return Explanation.match(score, getQuery().toString() + (score == 1f ? "" : "^" + score));
} else {
return Explanation.noMatch(getQuery().toString() + " doesn't match id " + doc);
}
```

This is kind of inconvenient as it makes it kind of hard to figure out which term finally really matched when one e.g. puts a BooleanQuery into the FILTER clause of another BooleanQuery.

---
Migrated from [LUCENE-8606](https://issues.apache.org/jira/browse/LUCENE-8606) by Christian Ziech
Attachments: [0001-LUCENE-8606-adding-a-constructor-for-the-ConstantSco.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-8606/0001-LUCENE-8606-adding-a-constructor-for-the-ConstantSco.patch), [0001-LUCENE-8606-overwriting-the-explain-method-for-Cachi.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-8606/0001-LUCENE-8606-overwriting-the-explain-method-for-Cachi.patch)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.