LUCENE-10442: When indexQuery or/and dvQuery be a MatchAllDocsQuery then IndexOrDocValuesQuery should be rewrite to MatchAllDocsQuery (#715)

This commit is contained in:
Lu Xugang 2022-03-01 01:46:32 +08:00 committed by GitHub
parent 466278e149
commit 6224d0b157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -234,6 +234,9 @@ Optimizations
* LUCENE-10084, LUCENE-10435: Rewrite DocValuesFieldExistsQuery to MatchAllDocsQuery whenever
terms or points have a docCount that is equal to maxDoc. (Vigya Sharma, Lu Xugang)
* LUCENE-10442: When indexQuery or/and dvQuery be a MatchAllDocsQuery
then IndexOrDocValuesQuery should be rewrite to MatchAllDocsQuery. (Lu Xugang)
Changes in runtime behavior
---------------------

View File

@ -104,6 +104,10 @@ public final class IndexOrDocValuesQuery extends Query {
public Query rewrite(IndexReader reader) throws IOException {
Query indexRewrite = indexQuery.rewrite(reader);
Query dvRewrite = dvQuery.rewrite(reader);
if (indexRewrite.getClass() == MatchAllDocsQuery.class
|| dvRewrite.getClass() == MatchAllDocsQuery.class) {
return new MatchAllDocsQuery();
}
if (indexQuery != indexRewrite || dvQuery != dvRewrite) {
return new IndexOrDocValuesQuery(indexRewrite, dvRewrite);
}