public abstract class CollapsingTopDocsCollector<T>
extends org.apache.lucene.search.grouping.FirstPassGroupingCollector<T>
CollapseTopFieldDocs
output. The collapsing is done in a single pass by selecting only the top sorted document per collapse key.
The value used for the collapse key of each group can be found in CollapseTopFieldDocs.collapseValues
.Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
collapseField |
protected org.apache.lucene.search.Scorer |
scorer |
protected org.apache.lucene.search.Sort |
sort |
Modifier and Type | Method and Description |
---|---|
void |
collect(int doc) |
static CollapsingTopDocsCollector<?> |
createKeyword(java.lang.String collapseField,
org.apache.lucene.search.Sort sort,
int topN,
boolean trackMaxScore)
Create a collapsing top docs collector on a
SortedDocValues field. |
static CollapsingTopDocsCollector<?> |
createNumeric(java.lang.String collapseField,
org.apache.lucene.search.Sort sort,
int topN,
boolean trackMaxScore)
Create a collapsing top docs collector on a
NumericDocValues field. |
CollapseTopFieldDocs |
getTopDocs()
Transform
FirstPassGroupingCollector.getTopGroups(int, boolean) output in
CollapseTopFieldDocs . |
boolean |
needsScores() |
void |
setScorer(org.apache.lucene.search.Scorer scorer) |
protected final java.lang.String collapseField
protected final org.apache.lucene.search.Sort sort
protected org.apache.lucene.search.Scorer scorer
public CollapseTopFieldDocs getTopDocs()
FirstPassGroupingCollector.getTopGroups(int, boolean)
output in
CollapseTopFieldDocs
. The collapsing needs only one pass so we can create the final top docs at the end
of the first pass.public boolean needsScores()
needsScores
in interface org.apache.lucene.search.Collector
needsScores
in class org.apache.lucene.search.grouping.FirstPassGroupingCollector<T>
public void setScorer(org.apache.lucene.search.Scorer scorer) throws java.io.IOException
setScorer
in interface org.apache.lucene.search.LeafCollector
setScorer
in class org.apache.lucene.search.grouping.FirstPassGroupingCollector<T>
java.io.IOException
public void collect(int doc) throws java.io.IOException
collect
in interface org.apache.lucene.search.LeafCollector
collect
in class org.apache.lucene.search.grouping.FirstPassGroupingCollector<T>
java.io.IOException
public static CollapsingTopDocsCollector<?> createNumeric(java.lang.String collapseField, org.apache.lucene.search.Sort sort, int topN, boolean trackMaxScore) throws java.io.IOException
NumericDocValues
field.
It accepts also SortedNumericDocValues
field but
the collect will fail with an IllegalStateException
if a document contains more than one value for the
field.collapseField
- The sort field used to group
documents.sort
- The Sort
used to sort the collapsed hits.
The collapsing keeps only the top sorted document per collapsed key.
This must be non-null, ie, if you want to groupSort by relevance
use Sort.RELEVANCE.topN
- How many top groups to keep.java.io.IOException
- When I/O related errors occurpublic static CollapsingTopDocsCollector<?> createKeyword(java.lang.String collapseField, org.apache.lucene.search.Sort sort, int topN, boolean trackMaxScore) throws java.io.IOException
SortedDocValues
field.
It accepts also SortedSetDocValues
field but
the collect will fail with an IllegalStateException
if a document contains more than one value for the
field.collapseField
- The sort field used to group
documents.sort
- The Sort
used to sort the collapsed hits. The collapsing keeps only the top sorted
document per collapsed key.
This must be non-null, ie, if you want to groupSort by relevance use Sort.RELEVANCE.topN
- How many top groups to keep.java.io.IOException
- When I/O related errors occur