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 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)
.
SortedSetSelector
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,
SortedSetSelector.Type 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)
Returns true if
o is equal to this. |
FieldComparator<?> |
getComparator(int numHits,
int sortPos)
Returns the
FieldComparator to use for
sorting. |
SortedSetSelector.Type |
getSelector()
Returns the selector in use for this sort
|
int |
hashCode()
Returns a hash code for this
SortField instance. |
void |
setMissingValue(Object missingValue)
Set how missing values (the empty set) are sorted.
|
String |
toString() |
getBytesComparator, getComparatorSource, getField, getMissingValue, 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, SortedSetSelector.Type selector)
field
- Name of field to sort by. Must not be null.reverse
- True if natural order should be reversed.selector
- custom selector type for choosing the sort value from the set.
NOTE: selectors other than SortedSetSelector.Type.MIN
require optional codec support.
public SortedSetSelector.Type getSelector()
public int hashCode()
SortField
SortField
instance. If a
FieldComparatorSource
was provided, it must properly
implement hashCode (unless a singleton is always used).public boolean equals(Object obj)
SortField
o
is equal to this. If a
FieldComparatorSource
was provided, it must properly
implement equals (unless a singleton is always used).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
SortField
FieldComparator
to use for
sorting.getComparator
in class SortField
numHits
- number of top hits the queue will storesortPos
- position of this SortField within Sort
. The comparator is primary if sortPos==0,
secondary if sortPos==1, etc. Some comparators can
optimize themselves when they are the primary sort.FieldComparator
to use when sortingIOException
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.