Class NRTSuggester
java.lang.Object
org.apache.lucene.search.suggest.document.NRTSuggester
- All Implemented Interfaces:
Accountable
NRTSuggester executes Top N search on a weighted FST specified by a
CompletionScorer
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
Modifier and TypeMethodDescriptionstatic 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
-
Method Details
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsed
in interfaceAccountable
-
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
-