Module org.apache.lucene.suggest
Class CompletionScorer
java.lang.Object
org.apache.lucene.search.BulkScorer
org.apache.lucene.search.suggest.document.CompletionScorer
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) and score(float, float) is called for every matched
completion (i.e. document)
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final Automatonprivate final Bits(package private) final boolean(package private) final LeafReaderprivate final NRTSuggesterprotected final CompletionWeightweight that created this scorer -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCompletionScorer(CompletionWeight weight, NRTSuggester suggester, LeafReader reader, Bits filterDocs, boolean filtered, Automaton automaton) Creates a scorer for a field-specificsuggesterscoped byacceptDocs -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanReturns true if a document withdocIDis accepted, false if the docID maps to a deleted document or has been filtered outlongcost()Same asDocIdSetIterator.cost()for bulk scorers.floatscore(float weight, float boost) Returns the score for a matched completion based on the query time boost and the index time weight.intscore(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 Details
-
suggester
-
filterDocs
-
weight
weight that created this scorer -
reader
-
filtered
final boolean filtered -
automaton
-
-
Constructor Details
-
CompletionScorer
protected CompletionScorer(CompletionWeight weight, NRTSuggester suggester, LeafReader reader, Bits filterDocs, boolean filtered, Automaton automaton) throws IOException Creates a scorer for a field-specificsuggesterscoped byacceptDocs- Throws:
IOException
-
-
Method Details
-
score
Description copied from class:BulkScorerCollects 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_DOCSif there are no more matches,- <= the first matching document that is >=
maxotherwise.
minis the minimum document to be considered for matching. All documents strictly before this value must be ignored.Although
maxwould 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:
scorein classBulkScorer- Parameters:
collector- The collector to which all matching documents are passed.acceptDocs-Bitsthat represents the allowed documents to match, ornullif 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:
IOException
- >=
-
cost
public long cost()Description copied from class:BulkScorerSame asDocIdSetIterator.cost()for bulk scorers.- Specified by:
costin classBulkScorer
-
accept
Returns true if a document withdocIDis accepted, false if the docID maps to a deleted document or has been filtered out- Parameters:
liveDocs- theBitsrepresenting live docs, or possiblynullif 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.
-