Class BulkScorer

java.lang.Object
org.apache.lucene.search.BulkScorer
Direct Known Subclasses:
BlockMaxConjunctionBulkScorer, BooleanScorer, CompletionScorer, ConjunctionBulkScorer, ConstantScoreQuery.ConstantBulkScorer, DrillSidewaysScorer, MaxScoreBulkScorer, ReqExclBulkScorer, TimeLimitingBulkScorer, ToParentBlockJoinQuery.BlockJoinBulkScorer, Weight.DefaultBulkScorer

public abstract class BulkScorer extends Object
This class is used to score a range of documents at once, and is returned by Weight.bulkScorer(org.apache.lucene.index.LeafReaderContext). Only queries that have a more optimized means of scoring across a range of documents need to override this. Otherwise, a default implementation is wrapped around the Scorer returned by Weight.scorer(org.apache.lucene.index.LeafReaderContext).
  • Constructor Details

    • BulkScorer

      public BulkScorer()
  • Method Details

    • score

      @Deprecated public void score(LeafCollector collector, Bits acceptDocs) throws IOException
      Deprecated.
      in favour of score(LeafCollector, Bits, int, int). Callers should instead call the method variant that takes min and max as arguments, providing 0 and DocIdSetIterator.NO_MORE_DOCS to score the entire segment. Subclasses that override it should instead override its replacement.
      Scores and collects all matching documents.
      Parameters:
      collector - The collector to which all matching documents are passed.
      acceptDocs - Bits that represents the allowed documents to match, or null if they are all allowed to match.
      Throws:
      IOException
    • score

      public abstract int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException
      Collects matching documents in a range and return an estimation of the next matching document which is on or after max.

      The return value must be:

      min is the minimum document to be considered for matching. All documents strictly before this value must be ignored.

      Although max would be a legal return value for this method, higher values might help callers skip more efficiently over non-matching portions of the docID space.

      For instance, a Scorer-based implementation could look like below:

       private final Scorer scorer; // set via constructor
      
       public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException {
         collector.setScorer(scorer);
         int doc = scorer.docID();
         if (doc < min) {
           doc = scorer.advance(min);
         }
         while (doc < max) {
           if (acceptDocs == null || acceptDocs.get(doc)) {
             collector.collect(doc);
           }
           doc = scorer.nextDoc();
         }
         return doc;
       }
       
      Parameters:
      collector - The collector to which all matching documents are passed.
      acceptDocs - Bits that represents the allowed documents to match, or null if they are all allowed to match.
      min - Score starting at, including, this document
      max - Score up to, but not including, this doc
      Returns:
      an under-estimation of the next matching doc after max
      Throws:
      IOException
    • cost

      public abstract long cost()
      Same as DocIdSetIterator.cost() for bulk scorers.