public class SortField extends Object
Created: Feb 11, 2004 1:25:29 PM
Sort| Modifier and Type | Class and Description | 
|---|---|
| static class  | SortField.ProviderA SortFieldProvider for field sorts | 
| static class  | SortField.TypeSpecifies the type of the terms to be sorted, or special types such as CUSTOM | 
| Modifier and Type | Field and Description | 
|---|---|
| static SortField | FIELD_DOCRepresents sorting by document number (index order). | 
| static SortField | FIELD_SCORERepresents sorting by document score (relevance). | 
| protected Object | missingValue | 
| static Object | STRING_FIRSTPass this to  setMissingValue(java.lang.Object)to have missing
  string values sort first. | 
| static Object | STRING_LASTPass this to  setMissingValue(java.lang.Object)to have missing
  string values sort last. | 
| Constructor and Description | 
|---|
| SortField(String field,
         FieldComparatorSource comparator)Creates a sort with a custom comparison function. | 
| SortField(String field,
         FieldComparatorSource comparator,
         boolean reverse)Creates a sort, possibly in reverse, with a custom comparison function. | 
| SortField(String field,
         SortField.Type type)Creates a sort by terms in the given field with the type of term
 values explicitly given. | 
| SortField(String field,
         SortField.Type type,
         boolean reverse)Creates a sort, possibly in reverse, by terms in the given field with the
 type of term values explicitly given. | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | equals(Object o)Returns true if  ois equal to this. | 
| Comparator<BytesRef> | getBytesComparator() | 
| boolean | getCanUsePoints() | 
| FieldComparator<?> | getComparator(int numHits,
             int sortPos)Returns the  FieldComparatorto use for
 sorting. | 
| FieldComparatorSource | getComparatorSource()Returns the  FieldComparatorSourceused for
 custom sorting | 
| String | getField()Returns the name of the field. | 
| IndexSorter | getIndexSorter()Returns an  IndexSorterused for sorting index segments by this SortField. | 
| Object | getMissingValue()Return the value to use for documents that don't have a value. | 
| boolean | getReverse()Returns whether the sort should be reversed. | 
| SortField.Type | getType()Returns the type of contents in the field. | 
| int | hashCode()Returns a hash code for this  SortFieldinstance. | 
| boolean | needsScores()Whether the relevance score is needed to sort documents. | 
| protected static SortField.Type | readType(DataInput in) | 
| SortField | rewrite(IndexSearcher searcher)Rewrites this SortField, returning a new SortField if a change is made. | 
| void | setBytesComparator(Comparator<BytesRef> b) | 
| void | setCanUsePoints()For numeric sort fields, setting this field, indicates that
 the same numeric data has been indexed with two fields: doc values and points and
 that these fields have the same name. | 
| void | setMissingValue(Object missingValue)Set the value to use for documents that don't have a value. | 
| String | toString() | 
public static final SortField FIELD_SCORE
public static final SortField FIELD_DOC
protected Object missingValue
public static final Object STRING_FIRST
setMissingValue(java.lang.Object) to have missing
  string values sort first.public static final Object STRING_LAST
setMissingValue(java.lang.Object) to have missing
  string values sort last.public SortField(String field, SortField.Type type)
field - Name of field to sort by.  Can be null if
               type is SCORE or DOC.type - Type of values in the terms.public SortField(String field, SortField.Type type, boolean reverse)
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.public SortField(String field, FieldComparatorSource comparator)
field - Name of field to sort by; cannot be null.comparator - Returns a comparator for sorting hits.public SortField(String field, FieldComparatorSource comparator, boolean reverse)
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.protected static SortField.Type readType(DataInput in) throws IOException
IOExceptionpublic Object getMissingValue()
null indicates that default should be used.public void setMissingValue(Object missingValue)
public String getField()
null
 if the sort is by SCORE or DOC.null.public SortField.Type getType()
public boolean getReverse()
public FieldComparatorSource getComparatorSource()
FieldComparatorSource used for
 custom sortingpublic void setCanUsePoints()
public boolean getCanUsePoints()
public boolean equals(Object o)
o is equal to this.  If a
  FieldComparatorSource was provided, it must properly
  implement equals (unless a singleton is always used).
  canUsePoints field is not part of equals and
  hasCode intentionally, as it is only useful during search-time and
  using it in these functions prevents index sorting optimizations
  that rely on the equality of the index-time and search-time SortField instances.public int hashCode()
SortField instance.  If a
  FieldComparatorSource was provided, it must properly
  implement hashCode (unless a singleton is always used).public void setBytesComparator(Comparator<BytesRef> b)
public Comparator<BytesRef> getBytesComparator()
public FieldComparator<?> getComparator(int numHits, int sortPos)
FieldComparator to use for
 sorting.numHits - number of top hits the queue will storesortPos - 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 sortingpublic SortField rewrite(IndexSearcher searcher) throws IOException
SortField.Type.REWRITEABLEsearcher - IndexSearcher to use during rewritingthis if nothing has changed.IOException - Can be thrown by the rewritingpublic boolean needsScores()
public IndexSorter getIndexSorter()
IndexSorter 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
 headersCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.