public class CompletionScorer extends BulkScorer
score(LeafCollector, Bits, int, int)
is called
for each leaf reader.
accept(int,Bits)
and score(float, float)
is called for every matched completion (i.e. document)Modifier and Type | Field and Description |
---|---|
protected CompletionWeight |
weight
weight that created this scorer
|
Modifier | Constructor and Description |
---|---|
protected |
CompletionScorer(CompletionWeight weight,
NRTSuggester suggester,
LeafReader reader,
Bits filterDocs,
boolean filtered,
Automaton automaton)
Creates a scorer for a field-specific
suggester scoped by acceptDocs |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(int docID,
Bits liveDocs)
Returns true if a document with
docID is accepted,
false if the docID maps to a deleted
document or has been filtered out |
long |
cost()
Same as
DocIdSetIterator.cost() for bulk scorers. |
float |
score(float weight,
float boost)
Returns the score for a matched completion
based on the query time boost and the
index time weight.
|
int |
score(LeafCollector collector,
Bits acceptDocs,
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 . |
score
protected final CompletionWeight weight
protected CompletionScorer(CompletionWeight weight, NRTSuggester suggester, LeafReader reader, Bits filterDocs, boolean filtered, Automaton automaton) throws java.io.IOException
suggester
scoped by acceptDocs
java.io.IOException
public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws java.io.IOException
BulkScorer
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, 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; }
score
in class BulkScorer
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 documentmax
- Score up to, but not including, this docjava.io.IOException
public long cost()
BulkScorer
DocIdSetIterator.cost()
for bulk scorers.cost
in class BulkScorer
public final boolean accept(int docID, Bits liveDocs)
docID
is accepted,
false if the docID maps to a deleted
document or has been filtered outliveDocs
- the Bits
representing live docs, or possibly
null
if all docs are livepublic float score(float weight, float boost)
Copyright © 2000–2019 The Apache Software Foundation. All rights reserved.