java.lang.Object | |
↳ | org.apache.lucene.search.SortField |
Stores information about how to sort documents by terms in an individual field. Fields must be indexed in order to sort by them.
Created: Feb 11, 2004 1:25:29 PM
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | BYTE | Sort using term values as encoded Bytes. | |||||||||
int | CUSTOM | Sort using a custom Comparator. | |||||||||
int | DOC | Sort by document number (index order). | |||||||||
int | DOUBLE | Sort using term values as encoded Doubles. | |||||||||
int | FLOAT | Sort using term values as encoded Floats. | |||||||||
int | INT | Sort using term values as encoded Integers. | |||||||||
int | LONG | Sort using term values as encoded Longs. | |||||||||
int | SCORE | Sort by document score (relevancy). | |||||||||
int | SHORT | Sort using term values as encoded Shorts. | |||||||||
int | STRING | Sort using term values as Strings. | |||||||||
int | STRING_VAL | Sort using term values as Strings, but comparing by value (using String.compareTo) for all comparisons. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
FIELD_DOC | Represents sorting by document number (index order). | ||||||||||
FIELD_SCORE | Represents sorting by document score (relevancy). |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a sort by terms in the given field with the type of term
values explicitly given.
| |||||||||||
Creates a sort, possibly in reverse, by terms in the given field with the
type of term values explicitly given.
| |||||||||||
Creates a sort by terms in the given field, parsed
to numeric values using a custom
FieldCache.Parser . | |||||||||||
Creates a sort, possibly in reverse, by terms in the given field, parsed
to numeric values using a custom
FieldCache.Parser . | |||||||||||
Creates a sort by terms in the given field sorted
according to the given locale.
| |||||||||||
Creates a sort, possibly in reverse, by terms in the given field sorted
according to the given locale.
| |||||||||||
Creates a sort with a custom comparison function.
| |||||||||||
Creates a sort, possibly in reverse, with a custom comparison function.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns true if
o is equal to this. | |||||||||||
Returns the
FieldComparator to use for
sorting. | |||||||||||
Returns the
FieldComparatorSource used for
custom sorting
| |||||||||||
Returns the name of the field.
| |||||||||||
Returns the Locale by which term values are interpreted.
| |||||||||||
Returns the instance of a
FieldCache parser that fits to the given sort type. | |||||||||||
Returns whether the sort should be reversed.
| |||||||||||
Returns the type of contents in the field.
| |||||||||||
Returns true if
o is equal to this. | |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Sort using term values as encoded Bytes. Sort values are Byte and lower values are at the front.
Sort using a custom Comparator. Sort values are any Comparable and sorting is done according to natural order.
Sort by document number (index order). Sort values are Integer and lower values are at the front.
Sort using term values as encoded Doubles. Sort values are Double and lower values are at the front.
Sort using term values as encoded Floats. Sort values are Float and lower values are at the front.
Sort using term values as encoded Integers. Sort values are Integer and lower values are at the front.
Sort using term values as encoded Longs. Sort values are Long and lower values are at the front.
Sort by document score (relevancy). Sort values are Float and higher values are at the front.
Sort using term values as encoded Shorts. Sort values are Short and lower values are at the front.
Sort using term values as Strings. Sort values are String and lower values are at the front.
Sort using term values as Strings, but comparing by
value (using String.compareTo) for all comparisons.
This is typically slower than STRING
, which
uses ordinals to do the sorting.
Creates a sort by terms in the given field with the type of term values explicitly given.
field | Name of field to sort by. Can be null if
type is SCORE or DOC. |
---|---|
type | Type of values in the terms. |
Creates a sort, possibly in reverse, by terms in the given field with the type of term values explicitly given.
field | Name of field to sort by. Can be null if
type is SCORE or DOC. |
---|---|
type | Type of values in the terms. |
reverse | True if natural order should be reversed. |
Creates a sort by terms in the given field, parsed
to numeric values using a custom FieldCache.Parser
.
field | Name of field to sort by. Must not be null. |
---|---|
parser | Instance of a FieldCache.Parser ,
which must subclass one of the existing numeric
parsers from FieldCache . Sort type is inferred
by testing which numeric parser the parser subclasses. |
IllegalArgumentException | if the parser fails to subclass an existing numeric parser, or field is null |
---|
Creates a sort, possibly in reverse, by terms in the given field, parsed
to numeric values using a custom FieldCache.Parser
.
field | Name of field to sort by. Must not be null. |
---|---|
parser | Instance of a FieldCache.Parser ,
which must subclass one of the existing numeric
parsers from FieldCache . Sort type is inferred
by testing which numeric parser the parser subclasses. |
reverse | True if natural order should be reversed. |
IllegalArgumentException | if the parser fails to subclass an existing numeric parser, or field is null |
---|
Creates a sort by terms in the given field sorted according to the given locale.
field | Name of field to sort by, cannot be null . |
---|---|
locale | Locale of values in the field. |
Creates a sort, possibly in reverse, by terms in the given field sorted according to the given locale.
field | Name of field to sort by, cannot be null . |
---|---|
locale | Locale of values in the field. |
Creates a sort with a custom comparison function.
field | Name of field to sort by; cannot be null . |
---|---|
comparator | Returns a comparator for sorting hits. |
Creates a sort, possibly in reverse, with a custom comparison function.
field | Name of field to sort by; cannot be null . |
---|---|
comparator | Returns a comparator for sorting hits. |
reverse | True if natural order should be reversed. |
Returns true if o
is equal to this. If a
FieldComparatorSource
or FieldCache.Parser
was provided, it must properly
implement equals (unless a singleton is always used).
Returns the FieldComparator
to use for
sorting.
NOTE: This API is experimental and might change in
incompatible ways in the next release.
numHits | number of top hits the queue will store |
---|---|
sortPos | 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 sorting
IOException |
---|
Returns the FieldComparatorSource
used for
custom sorting
Returns the name of the field. Could return null
if the sort is by SCORE or DOC.
null
.
Returns the Locale by which term values are interpreted.
May return null
if no Locale was specified.
null
.
Returns the instance of a FieldCache
parser that fits to the given sort type.
May return null
if no parser was specified. Sorting is using the default parser then.
FieldCache
parser, or null
.
Returns whether the sort should be reversed.
Returns the type of contents in the field.
Returns true if o
is equal to this. If a
FieldComparatorSource
or FieldCache.Parser
was provided, it must properly
implement hashCode (unless a singleton is always
used).