Package org.apache.lucene.search
Class SortedNumericSortField
java.lang.Object
org.apache.lucene.search.SortField
org.apache.lucene.search.SortedNumericSortField
SortField for
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)
.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A SortFieldProvider for this sort fieldNested classes/interfaces inherited from class org.apache.lucene.search.SortField
SortField.Type
-
Field Summary
Fields inherited from class org.apache.lucene.search.SortField
FIELD_DOC, FIELD_SCORE, missingValue, STRING_FIRST, STRING_LAST
-
Constructor Summary
ConstructorDescriptionSortedNumericSortField
(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. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true ifo
is equal to this.getComparator
(int numHits, boolean enableSkipping) Returns theFieldComparator
to use for sorting.Returns anIndexSorter
used for sorting index segments by this SortField.Returns the numeric type in use for this sortReturns the selector in use for this sortint
hashCode()
Returns a hash code for thisSortField
instance.void
setMissingValue
(Object missingValue) Set the value to use for documents that don't have a value.toString()
Methods inherited from class org.apache.lucene.search.SortField
getBytesComparator, getComparatorSource, getField, getMissingValue, getOptimizeSortWithPoints, getReverse, getType, needsScores, readType, rewrite, setBytesComparator, setOptimizeSortWithPoints
-
Constructor Details
-
SortedNumericSortField
Creates a sort, by the minimum value in the set for the document.- Parameters:
field
- Name of field to sort by. Must not be null.type
- Type of values
-
SortedNumericSortField
Creates a sort, possibly in reverse, by the minimum value in the set for the document.- Parameters:
field
- Name of field to sort by. Must not be null.type
- Type of valuesreverse
- True if natural order should be reversed.
-
SortedNumericSortField
public 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.- Parameters:
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.
-
-
Method Details
-
getNumericType
Returns the numeric type in use for this sort -
getSelector
Returns the selector in use for this sort -
hashCode
public int hashCode()Description copied from class:SortField
Returns a hash code for thisSortField
instance. If aFieldComparatorSource
was provided, it must properly implement hashCode (unless a singleton is always used). -
equals
Description copied from class:SortField
Returns true ifo
is equal to this. If aFieldComparatorSource
was provided, it must properly implement equals (unless a singleton is always used). -
toString
-
setMissingValue
Description copied from class:SortField
Set the value to use for documents that don't have a value.- Overrides:
setMissingValue
in classSortField
-
getComparator
Description copied from class:SortField
Returns theFieldComparator
to use for sorting.- Overrides:
getComparator
in classSortField
- Parameters:
numHits
- number of top hits the queue will storeenableSkipping
- true if the comparator can skip documents viaLeafFieldComparator.competitiveIterator()
- Returns:
FieldComparator
to use when sorting
-
getIndexSorter
Description copied from class:SortField
Returns anIndexSorter
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 headers- Overrides:
getIndexSorter
in classSortField
-