SortField for 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).
<init>(String field, boolean reverse)Creates a sort, possibly in reverse, by the minimum value in the set for the document.
| name | type | description |
|---|---|---|
| field | String | Name of field to sort by. Must not be null. |
| reverse | boolean | True if natural order should be reversed. |
<init>(String field, boolean reverse, org.apache.lucene.search.SortedSetSelector.Type selector)<init>(String field, boolean reverse, org.apache.lucene.search.SortedSetSelector.Type selector, Object missingValue)Creates a sort, possibly in reverse, specifying how the sort value from the document's set is selected.
| name | type | description |
|---|---|---|
| field | String | Name of field to sort by. Must not be null. |
| reverse | boolean | True if natural order should be reversed. |
| selector | org.apache.lucene.search.SortedSetSelector.Type | custom selector type for choosing the sort value from the set.
NOTE: selectors other than |
equals(Object obj)getComparator(int numHits, org.apache.lucene.search.Pruning pruning)hashCode()setMissingValue(Object missingValue) · also: set_missing_valueSet how missing values (the empty set) are sorted.
Note that this must be #STRING_FIRST or #STRING_LAST.
Returns the selector in use for this sort
toString()| field | type | note |
|---|---|---|
| FIELD_DOC | SortField | Represents sorting by document number (index order). |
| FIELD_SCORE | SortField | Represents sorting by document score (relevance). |
| STRING_FIRST | Object | Pass this to #setMissingValue to have missing string values sort first. |
| STRING_LAST | Object | Pass this to #setMissingValue to have missing string values sort last. |
getComparatorSource() · also: get_comparator_sourceReturns the FieldComparatorSource used for custom sorting
getField() · also: get_fieldReturns the name of the field. Could return null if the sort is by SCORE or DOC.
Returns: Name of field, possibly null.
getMissingValue() · also: get_missing_valueReturn the value to use for documents that don't have a value. A value of null
indicates that default should be used.
needsScores()Whether the relevance score is needed to sort documents.
getOptimizeSortWithIndexedData() · also: get_optimize_sort_with_indexed_dataReturns whether sort optimization should be optimized with indexed data
Returns: whether sort optimization should be optimized with indexed data
setOptimizeSortWithIndexedData(boolean optimizeSortWithIndexedData) · also: set_optimize_sort_with_indexed_dataEnables/disables numeric sort optimization to use the indexed data.
Enabled by default. By default, sorting on a numeric field activates point sort optimization that can efficiently skip over non-competitive hits. Sort optimization has a number of requirements, one of which is that SortField.Type matches the Point type with which the field was indexed (e.g. sort on IntPoint field should use SortField.Type.INT). Another requirement is that the same data is indexed with points and doc values for the field.
By default, sorting on a SORTED(_SET) field activates sort optimization that can efficiently skip over non-competitive hits. Sort optimization requires that the same data is indexed with term index and doc values for the field.
| name | type | description |
|---|---|---|
| optimize_sort_with_indexed_data | boolean | providing false disables the optimization, in cases
where these requirements can't be met. |
getOptimizeSortWithPoints() · also: get_optimize_sort_with_pointsSortField#getOptimizeSortWithIndexedData.
Returns whether sort optimization should be optimized with points index
Returns: whether sort optimization should be optimized with points index
setOptimizeSortWithPoints(boolean optimizeSortWithPoints) · also: set_optimize_sort_with_pointsSortField#setOptimizeSortWithIndexedData.
Enables/disables numeric sort optimization to use the Points index.
Enabled by default. By default, sorting on a numeric field activates point sort optimization that can efficiently skip over non-competitive hits. Sort optimization has a number of requirements, one of which is that SortField.Type matches the Point type with which the field was indexed (e.g. sort on IntPoint field should use SortField.Type.INT). Another requirement is that the same data is indexed with points and doc values for the field.
| name | type | description |
|---|---|---|
| optimize_sort_with_points | boolean | providing false disables the optimization, in cases where
these requirements can't be met. |
getReverse() · also: get_reverseReturns whether the sort should be reversed.
Returns: True if natural order should be reversed.
rewrite(org.apache.lucene.search.IndexSearcher searcher)Rewrites this SortField, returning a new SortField if a change is made. Subclasses should
override this define their rewriting behavior when this SortField is of type SortField.Type#REWRITEABLE
| name | type | description |
|---|---|---|
| searcher | org.apache.lucene.search.IndexSearcher | IndexSearcher to use during rewriting |
Returns: New rewritten SortField, or this if nothing has changed.
| IOException | Can be thrown by the rewriting | |
Returns the type of contents in the field.
Returns: One of the constants SCORE, DOC, STRING, INT or FLOAT.