org.apache.lucene.search
Class SortField
java.lang.Object
org.apache.lucene.search.SortField
- Serializable
public class SortField
extends java.lang.Object
implements Serializable
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
Version:
- Tim Jones (Nacimiento Software)
- lucene 1.4
Sort
static int | AUTO - Guess type of sort based on field contents.
|
static int | CUSTOM - Sort using a custom Comparator.
|
static int | DOC - Sort by document number (index order).
|
static SortField | FIELD_DOC - Represents sorting by document number (index order).
|
static SortField | FIELD_SCORE - Represents sorting by document score (relevancy).
|
static int | FLOAT - Sort using term values as encoded Floats.
|
static int | INT - Sort using term values as encoded Integers.
|
static int | SCORE - Sort by document score (relevancy).
|
static int | STRING - Sort using term values as Strings.
|
SortField(String field) - Creates a sort by terms in the given field where the type of term value
is determined dynamically (
AUTO ).
|
SortField(String field, Locale locale) - Creates a sort by terms in the given field sorted
according to the given locale.
|
SortField(String field, Locale locale, boolean reverse) - Creates a sort, possibly in reverse, by terms in the given field sorted
according to the given locale.
|
SortField(String field, boolean reverse) - Creates a sort, possibly in reverse, by terms in the given field where
the type of term value is determined dynamically (
AUTO ).
|
SortField(String field, int type) - Creates a sort by terms in the given field with the type of term
values explicitly given.
|
SortField(String field, int type, boolean reverse) - Creates a sort, possibly in reverse, by terms in the given field with the
type of term values explicitly given.
|
SortField(String field, SortComparatorSource comparator) - Creates a sort with a custom comparison function.
|
SortField(String field, SortComparatorSource comparator, boolean reverse) - Creates a sort, possibly in reverse, with a custom comparison function.
|
AUTO
public static final int AUTO
Guess type of sort based on field contents. A regular expression is used
to look at the first term indexed for the field and determine if it
represents an integer number, a floating point number, or just arbitrary
string characters.
- 2
CUSTOM
public static final int CUSTOM
Sort using a custom Comparator. Sort values are any Comparable and
sorting is done according to natural order.
- 9
DOC
public static final int DOC
Sort by document number (index order). Sort values are Integer and lower
values are at the front.
- 1
FIELD_DOC
public static final SortField FIELD_DOC
Represents sorting by document number (index order).
FIELD_SCORE
public static final SortField FIELD_SCORE
Represents sorting by document score (relevancy).
FLOAT
public static final int FLOAT
Sort using term values as encoded Floats. Sort values are Float and
lower values are at the front.
- 5
INT
public static final int INT
Sort using term values as encoded Integers. Sort values are Integer and
lower values are at the front.
- 4
SCORE
public static final int SCORE
Sort by document score (relevancy). Sort values are Float and higher
values are at the front.
- 0
STRING
public static final int STRING
Sort using term values as Strings. Sort values are String and lower
values are at the front.
- 3
SortField
public SortField(String field)
Creates a sort by terms in the given field where the type of term value
is determined dynamically (
AUTO
).
field
- Name of field to sort by, cannot be null
.
SortField
public SortField(String field,
Locale locale)
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.
SortField
public SortField(String field,
Locale locale,
boolean reverse)
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.
SortField
public SortField(String field,
boolean reverse)
Creates a sort, possibly in reverse, by terms in the given field where
the type of term value is determined dynamically (
AUTO
).
field
- Name of field to sort by, cannot be null
.reverse
- True if natural order should be reversed.
SortField
public SortField(String field,
int type)
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.
SortField
public SortField(String field,
int type,
boolean reverse)
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.
SortField
public SortField(String field,
SortComparatorSource comparator)
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.
SortField
public SortField(String field,
SortComparatorSource comparator,
boolean reverse)
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.
getField
public String getField()
Returns the name of the field. Could return null
if the sort is by SCORE or DOC.
- Name of field, possibly
null
.
getLocale
public Locale getLocale()
Returns the Locale by which term values are interpreted.
May return null
if no Locale was specified.
- Locale, or
null
.
getReverse
public boolean getReverse()
Returns whether the sort should be reversed.
- True if natural order should be reversed.
getType
public int getType()
Returns the type of contents in the field.
- One of the constants SCORE, DOC, AUTO, STRING, INT or FLOAT.
toString
public String toString()
Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.