Class TopSuggestDocsCollector
- java.lang.Object
-
- org.apache.lucene.search.SimpleCollector
-
- org.apache.lucene.search.suggest.document.TopSuggestDocsCollector
-
- All Implemented Interfaces:
Collector
,LeafCollector
public class TopSuggestDocsCollector extends SimpleCollector
Collector
that collects completion and score, along with document idNon scoring collector that collect completions in order of their pre-computed scores.
NOTE: One document can be collected multiple times if a document is matched for multiple unique completions for a given query
Subclasses should only override
collect(int, CharSequence, CharSequence, float)
.NOTE:
SimpleCollector.setScorer(org.apache.lucene.search.Scorable)
andcollect(int)
is not used
-
-
Field Summary
Fields Modifier and Type Field Description protected int
docBase
Document base offset for the current Leafprivate int
num
private java.util.List<TopSuggestDocs.SuggestScoreDoc>
pendingResults
Only set if we are deduplicating hits: holds all per-segment hits until the end, when we dedup themprivate SuggestScoreDocPriorityQueue
priorityQueue
(package private) CharArraySet
seenSurfaceForms
Only set if we are deduplicating hits: holds all surface forms seen so far in the current segment
-
Constructor Summary
Constructors Constructor Description TopSuggestDocsCollector(int num, boolean skipDuplicates)
Sole constructor Collects at mostnum
completions with corresponding document and weight
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
collect(int doc)
Ignoredvoid
collect(int docID, java.lang.CharSequence key, java.lang.CharSequence context, float score)
Called for every matched completion, similar toLeafCollector.collect(int)
but for completions.protected void
doSetNextReader(LeafReaderContext context)
This method is called before collectingcontext
.protected boolean
doSkipDuplicates()
Returns true if duplicates are filtered outTopSuggestDocs
get()
Returns at mostnum
Top scoringTopSuggestDocs
sint
getCountToCollect()
Returns the number of results to be collectedScoreMode
scoreMode()
Ignored-
Methods inherited from class org.apache.lucene.search.SimpleCollector
getLeafCollector, setScorer
-
-
-
-
Field Detail
-
priorityQueue
private final SuggestScoreDocPriorityQueue priorityQueue
-
num
private final int num
-
pendingResults
private final java.util.List<TopSuggestDocs.SuggestScoreDoc> pendingResults
Only set if we are deduplicating hits: holds all per-segment hits until the end, when we dedup them
-
seenSurfaceForms
final CharArraySet seenSurfaceForms
Only set if we are deduplicating hits: holds all surface forms seen so far in the current segment
-
docBase
protected int docBase
Document base offset for the current Leaf
-
-
Method Detail
-
doSkipDuplicates
protected boolean doSkipDuplicates()
Returns true if duplicates are filtered out
-
getCountToCollect
public int getCountToCollect()
Returns the number of results to be collected
-
doSetNextReader
protected void doSetNextReader(LeafReaderContext context) throws java.io.IOException
Description copied from class:SimpleCollector
This method is called before collectingcontext
.- Overrides:
doSetNextReader
in classSimpleCollector
- Throws:
java.io.IOException
-
collect
public void collect(int docID, java.lang.CharSequence key, java.lang.CharSequence context, float score) throws java.io.IOException
Called for every matched completion, similar toLeafCollector.collect(int)
but for completions. NOTE: collection at the leaf level is guaranteed to be in descending order of score- Throws:
java.io.IOException
-
get
public TopSuggestDocs get() throws java.io.IOException
Returns at mostnum
Top scoringTopSuggestDocs
s- Throws:
java.io.IOException
-
collect
public void collect(int doc) throws java.io.IOException
Ignored- Specified by:
collect
in interfaceLeafCollector
- Specified by:
collect
in classSimpleCollector
- Throws:
java.io.IOException
-
scoreMode
public ScoreMode scoreMode()
Ignored
-
-