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
|
(package private) static class |
DiversifiedTopDocsCollector.ScoreDocKeyQueue |
Modifier and Type | Field and Description |
---|---|
private DiversifiedTopDocsCollector.ScoreDocKeyQueue |
globalQueue |
protected int |
maxNumPerKey |
private int |
numHits |
private java.util.Map<java.lang.Long,DiversifiedTopDocsCollector.ScoreDocKeyQueue> |
perKeyQueues |
(package private) DiversifiedTopDocsCollector.ScoreDocKey |
spare |
private java.util.Stack<DiversifiedTopDocsCollector.ScoreDocKeyQueue> |
sparePerKeyQueues |
EMPTY_TOPDOCS, pq, totalHits, totalHitsRelation
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) |
protected TopDocs |
newTopDocs(ScoreDoc[] results,
int start)
Returns a
TopDocs instance containing the given results. |
private void |
perKeyGroupRemove(DiversifiedTopDocsCollector.ScoreDocKey globalOverflow) |
ScoreMode |
scoreMode()
Indicates what features are required from the scorer.
|
getTotalHits, populateResults, topDocs, topDocs, topDocs, topDocsSize
DiversifiedTopDocsCollector.ScoreDocKey spare
private DiversifiedTopDocsCollector.ScoreDocKeyQueue globalQueue
private int numHits
private java.util.Map<java.lang.Long,DiversifiedTopDocsCollector.ScoreDocKeyQueue> perKeyQueues
protected int maxNumPerKey
private java.util.Stack<DiversifiedTopDocsCollector.ScoreDocKeyQueue> sparePerKeyQueues
public DiversifiedTopDocsCollector(int numHits, int maxHitsPerKey)
protected abstract NumericDocValues getKeys(LeafReaderContext context)
public ScoreMode scoreMode()
Collector
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
private void perKeyGroupRemove(DiversifiedTopDocsCollector.ScoreDocKey globalOverflow)
public LeafCollector getLeafCollector(LeafReaderContext context) throws java.io.IOException
Collector
collector
to collect the given context.context
- next atomic reader contextjava.io.IOException