goankur commented on a change in pull request #293:
URL: https://github.com/apache/lucene/pull/293#discussion_r709691554



##########
File path: lucene/core/src/java/org/apache/lucene/search/ConjunctionUtils.java
##########
@@ -97,4 +99,46 @@ public static void addIterator(
       List<TwoPhaseIterator> twoPhaseIterators) {
     ConjunctionDISI.addIterator(disi, allIterators, twoPhaseIterators);
   }
+
+  /**
+   * Wrap the given DocIdSetIterator and liveDocs into another 
DocIdSetIterator that returns
+   * non-deleted documents during iteration. This is useful for match-all 
style queries that need to
+   * exclude deleted documents.
+   *
+   * @param it {@link DocIdSetIterator} being wrapped
+   * @param liveDocs {@link Bits} containing set bits for non-deleted docs
+   * @return wrapped iterator
+   */
+  public static DocIdSetIterator liveDocsDISI(DocIdSetIterator it, Bits 
liveDocs) {

Review comment:
       I created a new class - `org.apache.lucene.facet.FacetUtils` and moved 
the `liveDocsDISI(...)` method to that class.
   I modified the implementation to model the  
[doNext](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/search/ConjunctionDISI.java#L166)
 pattern as suggested. Both `advance(int docId)` and `nextDoc(int docId)` 
method now delegate to the corresponding methods of the wrapped DISI before 
invoking `doNext(int docId)`  which skips the docId until it finds one that is 
in the liveDocs or the wrapped DISI runs out of documents (i.e NO_MORE_DOCS).
   
   Unfortunately that class cannot be package private and that limits its 
visibility to other classes in a sub-package. Also added a new test case - 
`org.apache.lucene.facet.TestFacetUtils`
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to