Sort
object at
search time. Sorting on returned ResultDocs is less efficient and may cause OutOfMemory errors on
large result sets.public class LuceneFieldComparator
extends java.lang.Object
implements java.util.Comparator
ResultDoc
s for sorting by a given Lucene field. Fields that are
encoded as a Dates will be sorted by Date, all others are sorted lexically. The lucene fields must be
stored as text or keyword. The name of the field to be sorted must be passed into the constructor of this
LuceneFieldComparator.ResultDoc
Modifier and Type | Field and Description |
---|---|
static int |
ASCENDING
Deprecated.
Used to sort in ascending order.
|
static int |
DESCENDING
Deprecated.
Used to sort in descending order.
|
Constructor and Description |
---|
LuceneFieldComparator(java.lang.String fieldName,
int sortOrder)
Deprecated.
Sorting should now be done by supplying a
Sort object
at search time. Sorting on returned ResultDocs is less efficient and may cause OutOfMemory errors on
large result sets. |
Modifier and Type | Method and Description |
---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
Deprecated.
Compares two
ResultDoc s for sorting by a Lucene field, indicated at
construction time. |
public static final int ASCENDING
public static final int DESCENDING
public LuceneFieldComparator(java.lang.String fieldName, int sortOrder)
Sort
object
at search time. Sorting on returned ResultDocs is less efficient and may cause OutOfMemory errors on
large result sets.fieldName
- Field to sort bysortOrder
- ASCENDING or DESCENDINGpublic int compare(java.lang.Object o1, java.lang.Object o2)
ResultDoc
s for sorting by a Lucene field, indicated at
construction time.Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
compare
in interface java.util.Comparator
o1
- The first Object.o2
- The second Object.