Class CompletionScorer
- java.lang.Object
-
- org.apache.lucene.search.BulkScorer
-
- org.apache.lucene.search.suggest.document.CompletionScorer
-
public class CompletionScorer extends BulkScorer
Expert: Responsible for executing the query against an appropriate suggester and collecting the results via a collector.score(LeafCollector, Bits, int, int)
is called for each leaf reader.accept(int,Bits)
andscore(float, float)
is called for every matched completion (i.e. document)
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Automaton
automaton
private Bits
filterDocs
(package private) boolean
filtered
(package private) LeafReader
reader
private NRTSuggester
suggester
protected CompletionWeight
weight
weight that created this scorer
-
Constructor Summary
Constructors Modifier Constructor Description protected
CompletionScorer(CompletionWeight weight, NRTSuggester suggester, LeafReader reader, Bits filterDocs, boolean filtered, Automaton automaton)
Creates a scorer for a field-specificsuggester
scoped byacceptDocs
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(int docID, Bits liveDocs)
Returns true if a document withdocID
is accepted, false if the docID maps to a deleted document or has been filtered outlong
cost()
Same asDocIdSetIterator.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 aftermax
.-
Methods inherited from class org.apache.lucene.search.BulkScorer
score
-
-
-
-
Field Detail
-
suggester
private final NRTSuggester suggester
-
filterDocs
private final Bits filterDocs
-
weight
protected final CompletionWeight weight
weight that created this scorer
-
reader
final LeafReader reader
-
filtered
final boolean filtered
-
automaton
final Automaton automaton
-
-
Constructor Detail
-
CompletionScorer
protected CompletionScorer(CompletionWeight weight, NRTSuggester suggester, LeafReader reader, Bits filterDocs, boolean filtered, Automaton automaton) throws java.io.IOException
Creates a scorer for a field-specificsuggester
scoped byacceptDocs
- Throws:
java.io.IOException
-
-
Method Detail
-
score
public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws java.io.IOException
Description copied from class:BulkScorer
Collects matching documents in a range and return an estimation of the next matching document which is on or aftermax
.The return value must be:
- >=
max
, DocIdSetIterator.NO_MORE_DOCS
if there are no more matches,- <= the first matching document that is >=
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; }
- Specified by:
score
in classBulkScorer
- Parameters:
collector
- The collector to which all matching documents are passed.acceptDocs
-Bits
that represents the allowed documents to match, ornull
if they are all allowed to match.min
- Score starting at, including, this documentmax
- Score up to, but not including, this doc- Returns:
- an under-estimation of the next matching doc after max
- Throws:
java.io.IOException
- >=
-
cost
public long cost()
Description copied from class:BulkScorer
Same asDocIdSetIterator.cost()
for bulk scorers.- Specified by:
cost
in classBulkScorer
-
accept
public final boolean accept(int docID, Bits liveDocs)
Returns true if a document withdocID
is accepted, false if the docID maps to a deleted document or has been filtered out- Parameters:
liveDocs
- theBits
representing live docs, or possiblynull
if all docs are live
-
score
public float score(float weight, float boost)
Returns the score for a matched completion based on the query time boost and the index time weight.
-
-