public class SortedSetSortField extends SortField
SortedSetDocValues
.
A SortedSetDocValues contains multiple values for a field, so sorting with this technique "selects" a value as the representative sort value for the document.
By default, the minimum value in the set is selected as the sort value, but this can be customized. Selectors other than the default do have some limitations (see below) to ensure that all selections happen in constant-time for performance.
Like sorting by string, this also supports sorting missing values as first or last,
via setMissingValue(Object)
.
Limitations:
Integer.MAX_VALUE
or more unique values
are unsupported.
SortedSetSortField.Selector.MIN
) require
optional codec support. However several codecs provided by Lucene,
including the current default codec, support this.
Modifier and Type | Class and Description |
---|---|
static class |
SortedSetSortField.Selector
Selects a value from the document's set to use as the sort value
|
SortField.Type
FIELD_DOC, FIELD_SCORE, missingValue, STRING_FIRST, STRING_LAST
Constructor and Description |
---|
SortedSetSortField(String field,
boolean reverse)
Creates a sort, possibly in reverse, by the minimum value in the set
for the document.
|
SortedSetSortField(String field,
boolean reverse,
SortedSetSortField.Selector selector)
Creates a sort, possibly in reverse, specifying how the sort value from
the document's set is selected.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
FieldComparator<?> |
getComparator(int numHits,
int sortPos) |
SortedSetSortField.Selector |
getSelector()
Returns the selector in use for this sort
|
int |
hashCode() |
void |
setMissingValue(Object missingValue)
Set how missing values (the empty set) are sorted.
|
String |
toString() |
getBytesComparator, getComparatorSource, getField, getParser, getReverse, getType, needsScores, rewrite, setBytesComparator
public SortedSetSortField(String field, boolean reverse)
field
- Name of field to sort by. Must not be null.reverse
- True if natural order should be reversed.public SortedSetSortField(String field, boolean reverse, SortedSetSortField.Selector selector)
field
- Name of field to sort by. Must not be null.reverse
- True if natural order should be reversed.selector
- custom selector for choosing the sort value from the set.
NOTE: selectors other than SortedSetSortField.Selector.MIN
require optional codec support.
public SortedSetSortField.Selector getSelector()
public void setMissingValue(Object missingValue)
Note that this must be SortField.STRING_FIRST
or SortField.STRING_LAST
.
setMissingValue
in class SortField
public FieldComparator<?> getComparator(int numHits, int sortPos) throws IOException
getComparator
in class SortField
IOException
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.