public final 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 | Description |
---|---|---|
protected java.lang.String |
collapseField |
|
protected org.apache.lucene.search.Scorer |
scorer |
|
protected org.apache.lucene.search.Sort |
sort |
Modifier and Type | Method | 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) |
doSetNextReader, getGroupSelector, getTopGroups
protected final java.lang.String collapseField
protected final org.apache.lucene.search.Sort sort
protected org.apache.lucene.search.Scorer scorer
public CollapseTopFieldDocs getTopDocs() throws java.io.IOException
FirstPassGroupingCollector.getTopGroups(int, boolean)
output in
CollapseTopFieldDocs
. The collapsing needs only one pass so we can get the final top docs at the end
of the first pass.java.io.IOException
public boolean needsScores()
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 class org.apache.lucene.search.grouping.FirstPassGroupingCollector<T>
java.io.IOException
public void collect(int doc) throws java.io.IOException
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)
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.public static CollapsingTopDocsCollector<?> createKeyword(java.lang.String collapseField, org.apache.lucene.search.Sort sort, int topN, boolean trackMaxScore)
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.