You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mk...@apache.org on 2016/09/24 19:59:26 UTC

lucene-solr:branch_6x: LUCENE-7452: block join queries' exception message to suggest how to find a doc which, violates orthogonality restriction.

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x eb10b2c26 -> 45628f1a0


LUCENE-7452: block join queries' exception message to suggest how to
find a doc which, violates orthogonality restriction. 

Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/45628f1a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/45628f1a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/45628f1a

Branch: refs/heads/branch_6x
Commit: 45628f1a0b3d0f3b4b6fdb827aaf09252520d962
Parents: eb10b2c
Author: Mikhail Khludnev <mk...@apache.org>
Authored: Wed Sep 21 22:14:34 2016 +0300
Committer: Mikhail Khludnev <mk...@apache.org>
Committed: Sat Sep 24 22:59:20 2016 +0300

----------------------------------------------------------------------
 lucene/CHANGES.txt                              |  3 +++
 .../search/join/ToChildBlockJoinQuery.java      |  5 +++--
 .../search/join/ToParentBlockJoinQuery.java     | 21 +++++++++++---------
 .../search/join/TestBlockJoinValidation.java    |  4 ++--
 4 files changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/45628f1a/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 6d3da3e..a240a8e 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -20,6 +20,9 @@ Optimizations
 
 Other
 
+* LUCENE-7452: Block join query exception suggests how to find a doc, which 
+ violates orthogonality requirement. (Mikhail Khludnev)
+
 Build
 
 * LUCENE-7292: Fix build to use "--release 8" instead of "-release 8" on

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/45628f1a/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
----------------------------------------------------------------------
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
index 1518db0..830e29b 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
@@ -43,9 +43,10 @@ import org.apache.lucene.util.BitSet;
 public class ToChildBlockJoinQuery extends Query {
 
   /** Message thrown from {@link
-   *  ToChildBlockJoinScorer#validateParentDoc} on mis-use,
+   *  ToChildBlockJoinScorer#validateParentDoc} on misuse,
    *  when the parent query incorrectly returns child docs. */
-  static final String INVALID_QUERY_MESSAGE = "Parent query yields document which is not matched by parents filter, docID=";
+  static final String INVALID_QUERY_MESSAGE = "Parent query must not match any docs besides parent filter. "
+      + "Combine them as must (+) and must-not (-) clauses to find a problem doc. docID=";
   static final String ILLEGAL_ADVANCE_ON_PARENT = "Expect to be advanced on child docs only. got docID=";
 
   private final BitSetProducer parentsFilter;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/45628f1a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
----------------------------------------------------------------------
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
index aa28de4..83f9097 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
@@ -283,9 +283,7 @@ public class ToParentBlockJoinQuery extends Query {
 
           // Parent & child docs are supposed to be
           // orthogonal:
-          if (nextChildDoc == parentDoc) {
-            throw new IllegalStateException("child query must only match non-parent docs, but parent docID=" + nextChildDoc + " matched childScorer=" + childScorer.getClass());
-          }
+          checkOrthogonal(nextChildDoc, parentDoc);
 
           //System.out.println("  parentDoc=" + parentDoc);
           assert parentDoc != DocIdSetIterator.NO_MORE_DOCS;
@@ -326,9 +324,7 @@ public class ToParentBlockJoinQuery extends Query {
 
           // Parent & child docs are supposed to be
           // orthogonal:
-          if (nextChildDoc == parentDoc) {
-            throw new IllegalStateException("child query must only match non-parent docs, but parent docID=" + nextChildDoc + " matched childScorer=" + childScorer.getClass());
-          }
+          checkOrthogonal(nextChildDoc, parentDoc);
 
           switch(scoreMode) {
           case Avg:
@@ -381,9 +377,7 @@ public class ToParentBlockJoinQuery extends Query {
           }
 
           // Parent & child docs are supposed to be orthogonal:
-          if (nextChildDoc == prevParentDoc) {
-            throw new IllegalStateException("child query must only match non-parent docs, but parent docID=" + nextChildDoc + " matched childScorer=" + childScorer.getClass());
-          }
+          checkOrthogonal(nextChildDoc, prevParentDoc);
 
           final int nd = nextDoc();
           //System.out.println("  return nextParentDoc=" + nd);
@@ -402,6 +396,15 @@ public class ToParentBlockJoinQuery extends Query {
       };
     }
 
+    private void checkOrthogonal(int childDoc, int parentDoc) {
+      if (childDoc==parentDoc) {
+        throw new IllegalStateException("Child query must not match same docs with parent filter. "
+             + "Combine them as must clauses (+) to find a problem doc. "
+             + "docId=" + nextChildDoc + ", " + childScorer.getClass());
+        
+      }
+    }
+
     @Override
     public int docID() {
       return parentDoc;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/45628f1a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java
----------------------------------------------------------------------
diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java
index 565578c..aa68d09 100644
--- a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java
+++ b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java
@@ -84,7 +84,7 @@ public class TestBlockJoinValidation extends LuceneTestCase {
     IllegalStateException expected = expectThrows(IllegalStateException.class, () -> {
       indexSearcher.search(blockJoinQuery, 1);
     });
-    assertTrue(expected.getMessage() != null && expected.getMessage().contains("child query must only match non-parent docs"));
+    assertTrue(expected.getMessage() != null && expected.getMessage().contains("Child query must not match same docs with parent filter"));
   }
 
   public void testAdvanceValidationForToParentBjq() throws Exception {
@@ -103,7 +103,7 @@ public class TestBlockJoinValidation extends LuceneTestCase {
     IllegalStateException expected = expectThrows(IllegalStateException.class, () -> {
       indexSearcher.search(conjunctionQuery.build(), 1);
     });
-    assertTrue(expected.getMessage() != null && expected.getMessage().contains("child query must only match non-parent docs"));
+    assertTrue(expected.getMessage() != null && expected.getMessage().contains("Child query must not match same docs with parent filter"));
   }
 
   public void testNextDocValidationForToChildBjq() throws Exception {