Class NRTSuggester
- java.lang.Object
-
- org.apache.lucene.search.suggest.document.NRTSuggester
-
- All Implemented Interfaces:
Accountable
public final class NRTSuggester extends Object implements Accountable
NRTSuggester executes Top N search on a weighted FST specified by aCompletionScorer
See
lookup(CompletionScorer, Bits, TopSuggestDocsCollector)
for more implementation details.FST Format:
- Input: analyzed forms of input terms
- Output: Pair<Long, BytesRef> containing weight, surface form and docID
NOTE:
- having too many deletions or using a very restrictive filter can make the search
inadmissible due to over-pruning of potential paths. See
CompletionScorer.accept(int, Bits)
- when matched documents are arbitrarily filtered (
CompletionScorer.filtered
set totrue
, it is assumed that the filter will roughly filter out half the number of documents that match the provided automaton - lookup performance will degrade as more accepted completions lead to filtered out documents
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Field Summary
-
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<Accountable>
getChildResources()
static NRTSuggester
load(IndexInput input, CompletionPostingsFormat.FSTLoadMode fstLoadMode)
void
lookup(CompletionScorer scorer, Bits acceptDocs, TopSuggestDocsCollector collector)
Collects at mostTopSuggestDocsCollector.getCountToCollect()
completions that match the providedCompletionScorer
.long
ramBytesUsed()
-
-
-
Method Detail
-
ramBytesUsed
public long ramBytesUsed()
- Specified by:
ramBytesUsed
in interfaceAccountable
-
getChildResources
public Collection<Accountable> getChildResources()
- Specified by:
getChildResources
in interfaceAccountable
-
lookup
public void lookup(CompletionScorer scorer, Bits acceptDocs, TopSuggestDocsCollector collector) throws IOException
Collects at mostTopSuggestDocsCollector.getCountToCollect()
completions that match the providedCompletionScorer
.The
CompletionScorer.automaton
is intersected with thefst
.CompletionScorer.weight
is used to compute boosts and/or extract context for each matched partial paths. A top N search is executed onfst
seeded with the matched partial paths. Upon reaching a completed path,CompletionScorer.accept(int, Bits)
andCompletionScorer.score(float, float)
is used on the document id, index weight and query boost to filter and score the entry, before being collected viaTopSuggestDocsCollector.collect(int, CharSequence, CharSequence, float)
- Throws:
IOException
-
load
public static NRTSuggester load(IndexInput input, CompletionPostingsFormat.FSTLoadMode fstLoadMode) throws IOException
- Throws:
IOException
-
-