You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2022/02/28 17:57:47 UTC

[lucene] branch branch_9x updated: LUCENE-10442: When indexQuery or/and dvQuery be a MatchAllDocsQuery then IndexOrDocValuesQuery should be rewrite to MatchAllDocsQuery (#715)

This is an automated email from the ASF dual-hosted git repository.

jpountz pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 9497524  LUCENE-10442: When indexQuery or/and dvQuery be a MatchAllDocsQuery  then IndexOrDocValuesQuery should be rewrite to MatchAllDocsQuery (#715)
9497524 is described below

commit 9497524cc2d1eea24c5dd3da10e46eda991a7df7
Author: Lu Xugang <q1...@Gmail.com>
AuthorDate: Tue Mar 1 01:46:32 2022 +0800

    LUCENE-10442: When indexQuery or/and dvQuery be a MatchAllDocsQuery  then IndexOrDocValuesQuery should be rewrite to MatchAllDocsQuery (#715)
---
 lucene/CHANGES.txt                                                    | 3 +++
 .../core/src/java/org/apache/lucene/search/IndexOrDocValuesQuery.java | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index ba95614..6bb505b 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -192,6 +192,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
 ---------------------
 
diff --git a/lucene/core/src/java/org/apache/lucene/search/IndexOrDocValuesQuery.java b/lucene/core/src/java/org/apache/lucene/search/IndexOrDocValuesQuery.java
index 1a12add..9ba52eb 100644
--- a/lucene/core/src/java/org/apache/lucene/search/IndexOrDocValuesQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/IndexOrDocValuesQuery.java
@@ -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);
     }