public abstract class BulkScorer extends Object
Weight.bulkScorer(org.apache.lucene.index.LeafReaderContext, org.apache.lucene.util.Bits)
. 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, org.apache.lucene.util.Bits)
.Constructor and Description |
---|
BulkScorer() |
Modifier and Type | Method and Description |
---|---|
abstract long |
cost()
Same as
DocIdSetIterator.cost() for bulk scorers. |
void |
score(LeafCollector collector)
Scores and collects all matching documents.
|
abstract int |
score(LeafCollector collector,
int min,
int max)
Collects matching documents in a range and return an estimation of the
next matching document which is on or after
max . |
public void score(LeafCollector collector) throws IOException
collector
- The collector to which all matching documents are passed.IOException
public abstract int score(LeafCollector collector, int min, int max) throws IOException
max
.
The return value must be:
max
,DocIdSetIterator.NO_MORE_DOCS
if there are no more matches,max
otherwise.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, int min, int max) throws IOException { collector.setScorer(scorer); int doc = scorer.docID(); if (doc < min) { doc = scorer.advance(min); } while (doc < max) { collector.collect(doc); doc = scorer.nextDoc(); } return doc; }
collector
- The collector to which all matching documents are passed.min
- Score starting at, including, this documentmax
- Score up to, but not including, this docIOException
public abstract long cost()
DocIdSetIterator.cost()
for bulk scorers.Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.