public class SortedNumericSortField extends SortField
SortedNumericDocValues.
A SortedNumericDocValues 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 list is selected as the sort value, but this can be customized.
Like sorting by string, this also supports sorting missing values as first or last,
via setMissingValue(Object).
SortedNumericSelector| Modifier and Type | Class and Description |
|---|---|
static class |
SortedNumericSortField.Provider
A SortFieldProvider for this sort field
|
SortField.TypeFIELD_DOC, FIELD_SCORE, missingValue, STRING_FIRST, STRING_LAST| Constructor and Description |
|---|
SortedNumericSortField(String field,
SortField.Type type)
Creates a sort, by the minimum value in the set
for the document.
|
SortedNumericSortField(String field,
SortField.Type type,
boolean reverse)
Creates a sort, possibly in reverse, by the minimum value in the set
for the document.
|
SortedNumericSortField(String field,
SortField.Type type,
boolean reverse,
SortedNumericSelector.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. |
IndexSorter |
getIndexSorter()
Returns an
IndexSorter used for sorting index segments by this SortField. |
SortField.Type |
getNumericType()
Returns the numeric type in use for this sort
|
SortedNumericSelector.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 the value to use for documents that don't have a value.
|
String |
toString() |
getBytesComparator, getCanUsePoints, getComparatorSource, getField, getMissingValue, getReverse, getType, needsScores, readType, rewrite, setBytesComparator, setCanUsePointspublic SortedNumericSortField(String field, SortField.Type type)
field - Name of field to sort by. Must not be null.type - Type of valuespublic SortedNumericSortField(String field, SortField.Type type, boolean reverse)
field - Name of field to sort by. Must not be null.type - Type of valuesreverse - True if natural order should be reversed.public SortedNumericSortField(String field, SortField.Type type, boolean reverse, SortedNumericSelector.Type selector)
field - Name of field to sort by. Must not be null.type - Type of valuesreverse - True if natural order should be reversed.selector - custom selector type for choosing the sort value from the set.public SortField.Type getNumericType()
public SortedNumericSelector.Type getSelector()
public int hashCode()
SortFieldSortField instance. If a
FieldComparatorSource was provided, it must properly
implement hashCode (unless a singleton is always used).public boolean equals(Object obj)
SortFieldo is equal to this. If a
FieldComparatorSource was provided, it must properly
implement equals (unless a singleton is always used).
canUsePoints field is not part of equals and
hasCode intentionally, as it is only useful during search-time and
using it in these functions prevents index sorting optimizations
that rely on the equality of the index-time and search-time SortField instances.public void setMissingValue(Object missingValue)
SortFieldsetMissingValue in class SortFieldpublic FieldComparator<?> getComparator(int numHits, int sortPos)
SortFieldFieldComparator to use for
sorting.getComparator in class SortFieldnumHits - 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 sortingpublic IndexSorter getIndexSorter()
SortFieldIndexSorter used for sorting index segments by this SortField.
If the SortField cannot be used for index sorting (for example, if it uses scores or
other query-dependent values) then this method should return null
SortFields that implement this method should also implement a companion
SortFieldProvider to serialize and deserialize the sort in index segment
headersgetIndexSorter in class SortFieldCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.