lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r1404250 - in /lucene/dev/branches/branch_4x/lucene: CHANGES.txt join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
Date Wed, 31 Oct 2012 17:00:31 GMT
Author: mvg
Date: Wed Oct 31 17:00:31 2012
New Revision: 1404250

URL: http://svn.apache.org/viewvc?rev=1404250&view=rev
Log:
LUCENE-4513: Fixed that deleted nested docs are scored into the parent doc.

Modified:
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt
    lucene/dev/branches/branch_4x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
    lucene/dev/branches/branch_4x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java

Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1404250&r1=1404249&r2=1404250&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Wed Oct 31 17:00:31 2012
@@ -97,6 +97,9 @@ Bug Fixes
   happened in the IndexWriter instance.  (Ivan Vasilev via Mike
   McCandless)
 
+* LUCENE-4513: Fixed that deleted nested docs are scored into the
+  parent doc when using ToParentBlockJoinQuery. (Martijn van Groningen)
+
 Optimizations
 
 * LUCENE-4512: Additional memory savings for CompressingStoredFieldsIndex.MEMORY_CHUNK

Modified: lucene/dev/branches/branch_4x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java?rev=1404250&r1=1404249&r2=1404250&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
Wed Oct 31 17:00:31 2012
@@ -160,8 +160,8 @@ public class ToParentBlockJoinQuery exte
     public Scorer scorer(AtomicReaderContext readerContext, boolean scoreDocsInOrder,
         boolean topScorer, Bits acceptDocs) throws IOException {
 
-      // Pass scoreDocsInOrder true, topScorer false to our sub:
-      final Scorer childScorer = childWeight.scorer(readerContext, true, false, null);
+      // Pass scoreDocsInOrder true, topScorer false to our sub and the live docs:
+      final Scorer childScorer = childWeight.scorer(readerContext, true, false, readerContext.reader().getLiveDocs());
 
       if (childScorer == null) {
         // No matches

Modified: lucene/dev/branches/branch_4x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java?rev=1404250&r1=1404249&r2=1404250&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
Wed Oct 31 17:00:31 2012
@@ -272,6 +272,62 @@ public class TestBlockJoin extends Lucen
     dir.close();
   }
 
+  public void testNestedDocScoringWithDeletes() throws Exception {
+    final Directory dir = newDirectory();
+    final RandomIndexWriter w = new RandomIndexWriter(
+        random(),
+        dir,
+        newIndexWriterConfig(TEST_VERSION_CURRENT,
+            new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
+
+    // Cannot assert this since we use NoMergePolicy:
+    w.setDoRandomForceMergeAssert(false);
+
+    List<Document> docs = new ArrayList<Document>();
+    docs.add(makeJob("java", 2007));
+    docs.add(makeJob("python", 2010));
+    docs.add(makeResume("Lisa", "United Kingdom"));
+    w.addDocuments(docs);
+
+    docs.clear();
+    docs.add(makeJob("c", 1999));
+    docs.add(makeJob("ruby", 2005));
+    docs.add(makeJob("java", 2006));
+    docs.add(makeResume("Frank", "United States"));
+    w.addDocuments(docs);
+
+    w.commit();
+    IndexSearcher s = newSearcher(DirectoryReader.open(dir));
+
+    ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(
+        NumericRangeQuery.newIntRange("year", 1990, 2010, true, true),
+        new CachingWrapperFilter(new QueryWrapperFilter(new TermQuery(new Term("docType",
"resume")))),
+        ScoreMode.Total
+    );
+
+    TopDocs topDocs = s.search(q, 10);
+    assertEquals(2, topDocs.totalHits);
+    assertEquals(6, topDocs.scoreDocs[0].doc);
+    assertEquals(3.0f, topDocs.scoreDocs[0].score, 0.0f);
+    assertEquals(2, topDocs.scoreDocs[1].doc);
+    assertEquals(2.0f, topDocs.scoreDocs[1].score, 0.0f);
+
+    s.getIndexReader().close();
+    w.deleteDocuments(new Term("skill", "java"));
+    w.close();
+    s = newSearcher(DirectoryReader.open(dir));
+
+    topDocs = s.search(q, 10);
+    assertEquals(2, topDocs.totalHits);
+    assertEquals(6, topDocs.scoreDocs[0].doc);
+    assertEquals(2.0f, topDocs.scoreDocs[0].score, 0.0f);
+    assertEquals(2, topDocs.scoreDocs[1].doc);
+    assertEquals(1.0f, topDocs.scoreDocs[1].score, 0.0f);
+
+    s.getIndexReader().close();
+    dir.close();
+  }
+
   private String[][] getRandomFields(int maxUniqueValues) {
 
     final String[][] fields = new String[_TestUtil.nextInt(random(), 2, 4)][];



Mime
View raw message