public abstract class DiversifiedTopDocsCollector extends TopDocsCollector<DiversifiedTopDocsCollector.ScoreDocKey>
TopDocsCollector
that controls diversity in results by ensuring no
more than maxHitsPerKey results from a common source are collected in the
final results.
An example application might be a product search in a marketplace where no
more than 3 results per retailer are permitted in search results.
To compare behaviour with other forms of collector, a useful analogy might be the problem of making a compilation album of 1967's top hit records:
Modifier and Type | Class and Description |
---|---|
static class |
DiversifiedTopDocsCollector.ScoreDocKey
An extension to ScoreDoc that includes a key used for grouping purposes
|
Modifier and Type | Field and Description |
---|---|
protected int |
maxNumPerKey |
EMPTY_TOPDOCS, pq, totalHits
Constructor and Description |
---|
DiversifiedTopDocsCollector(int numHits,
int maxHitsPerKey) |
Modifier and Type | Method and Description |
---|---|
protected abstract NumericDocValues |
getKeys(LeafReaderContext context)
Get a source of values used for grouping keys
|
LeafCollector |
getLeafCollector(LeafReaderContext context)
Create a new
collector to collect the given context. |
protected DiversifiedTopDocsCollector.ScoreDocKey |
insert(DiversifiedTopDocsCollector.ScoreDocKey addition,
int docBase,
NumericDocValues keys) |
boolean |
needsScores()
Indicates if document scores are needed by this collector.
|
protected TopDocs |
newTopDocs(ScoreDoc[] results,
int start)
Returns a
TopDocs instance containing the given results. |
getTotalHits, populateResults, topDocs, topDocs, topDocs, topDocsSize
public DiversifiedTopDocsCollector(int numHits, int maxHitsPerKey)
protected abstract NumericDocValues getKeys(LeafReaderContext context)
public boolean needsScores()
Collector
true
if scores are needed.protected TopDocs newTopDocs(ScoreDoc[] results, int start)
TopDocsCollector
TopDocs
instance containing the given results. If
results
is null it means there are no results to return,
either because there were 0 calls to collect() or because the arguments to
topDocs were invalid.newTopDocs
in class TopDocsCollector<DiversifiedTopDocsCollector.ScoreDocKey>
protected DiversifiedTopDocsCollector.ScoreDocKey insert(DiversifiedTopDocsCollector.ScoreDocKey addition, int docBase, NumericDocValues keys) throws java.io.IOException
java.io.IOException
public LeafCollector getLeafCollector(LeafReaderContext context) throws java.io.IOException
Collector
collector
to collect the given context.context
- next atomic reader contextjava.io.IOException
Copyright © 2000–2019 The Apache Software Foundation. All rights reserved.