Revision: 18271
          http://sourceforge.net/p/gate/code/18271
Author:   ian_roberts
Date:     2014-08-21 13:40:10 +0000 (Thu, 21 Aug 2014)
Log Message:
-----------
Re-instated filtering of deleted documents from search results, which appears 
to have been broken for quite some time without anyonr noticing...

Modified Paths:
--------------
    mimir/trunk/mimir-core/src/gate/mimir/search/RankingQueryRunnerImpl.java

Modified: 
mimir/trunk/mimir-core/src/gate/mimir/search/RankingQueryRunnerImpl.java
===================================================================
--- mimir/trunk/mimir-core/src/gate/mimir/search/RankingQueryRunnerImpl.java    
2014-08-21 13:36:37 UTC (rev 18270)
+++ mimir/trunk/mimir-core/src/gate/mimir/search/RankingQueryRunnerImpl.java    
2014-08-21 13:40:10 UTC (rev 18271)
@@ -139,6 +139,9 @@
           docIndex = (documentIndexes != null ? 
               documentIndexes[(int)(i - start)] : i);
           docId = documentIds.getLong(docIndex);
+          // don't need to check for deletion here as we know for sure that 
this
+          // doc ID is ok.  The only exception would be if it was deleted since
+          // this query was originally issued, but I think we can live with 
that
           long newDoc = queryExecutor.nextDocument(docId - 1);
           // sanity check
           if(newDoc == docId) {
@@ -201,7 +204,7 @@
       try{
         // collect all documents and their scores
         if(ranking) scorer.wrap(queryExecutor);
-        long docId = ranking ? scorer.nextDocument(-1) : 
queryExecutor.nextDocument(-1);
+        long docId = nextNotDeleted();
         while(docId >= 0) {
           // enlarge the hits list
           if(ranking){
@@ -223,7 +226,7 @@
           }
           // and store the new doc ID
           documentIds.add(docId);
-          docId = ranking ? scorer.nextDocument(-1) : 
queryExecutor.nextDocument(-1);
+          docId = nextNotDeleted();
         }
         allDocIdsCollected = true;
         if(ranking) {
@@ -734,4 +737,19 @@
       }      
     }
   }
+
+  /**
+   * Find the next document ID for the current query executor which is not
+   * marked as deleted in the index.
+   */
+  protected long nextNotDeleted() throws IOException {
+    long docId = ranking ? scorer.nextDocument(-1)
+                         : queryExecutor.nextDocument(-1);
+    while(docId >= 0 && queryEngine.getIndex().isDeleted(docId)) {
+      docId = ranking ? scorer.nextDocument(-1)
+                      : queryExecutor.nextDocument(-1);
+    }
+    
+    return docId;
+  }
 }
\ No newline at end of file

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
GATE-cvs mailing list
GATE-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to