LUCENE-10450: IndexSortSortedNumericDocValuesRangeQuery could be rewrite to MatchAllDocsQuery (#720)

This commit is contained in:
Lu Xugang 2022-03-02 16:28:40 +08:00 committed by GitHub
parent e8e522a52b
commit e996f1d8e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -245,6 +245,8 @@ Optimizations
* LUCENE-10442: When indexQuery or/and dvQuery be a MatchAllDocsQuery * LUCENE-10442: When indexQuery or/and dvQuery be a MatchAllDocsQuery
then IndexOrDocValuesQuery should be rewrite to MatchAllDocsQuery. (Lu Xugang) then IndexOrDocValuesQuery should be rewrite to MatchAllDocsQuery. (Lu Xugang)
* LUCENE-10450: IndexSortSortedNumericDocValuesRangeQuery could be rewrite to MatchAllDocsQuery. (Lu Xugang)
Changes in runtime behavior Changes in runtime behavior
--------------------- ---------------------

View File

@ -30,6 +30,7 @@ import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FieldComparator; import org.apache.lucene.search.FieldComparator;
import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.LeafFieldComparator; import org.apache.lucene.search.LeafFieldComparator;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor; import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.ScoreMode;
@ -140,6 +141,9 @@ public class IndexSortSortedNumericDocValuesRangeQuery extends Query {
} }
Query rewrittenFallback = fallbackQuery.rewrite(reader); Query rewrittenFallback = fallbackQuery.rewrite(reader);
if (rewrittenFallback.getClass() == MatchAllDocsQuery.class) {
return new MatchAllDocsQuery();
}
if (rewrittenFallback == fallbackQuery) { if (rewrittenFallback == fallbackQuery) {
return this; return this;
} else { } else {