You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/09/16 01:50:22 UTC

[GitHub] [lucene] goankur commented on a change in pull request #293: Lucene-10070: Skip deleted documents during facet counting for all do…

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-unsubscribe@lucene.apache.org

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



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