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:35:49 UTC

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

Repository: lucene-solr
Updated Branches:
  refs/heads/master 4733488ed -> 4ab8e9c26


LUCENE-7452: block join queries' exception message to suggest how to
find a doc which violate 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/4ab8e9c2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/4ab8e9c2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/4ab8e9c2

Branch: refs/heads/master
Commit: 4ab8e9c26291f8ffdc8c649f01ca3b464fc2ca5c
Parents: 4733488
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:31:58 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/4ab8e9c2/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index c7d71a2..366ad21 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -55,6 +55,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/4ab8e9c2/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 53f13b6..0b5c19b 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/4ab8e9c2/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 18a5d20..3abdeeb 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/4ab8e9c2/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 {