Class 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
@since lucene 1.4
Inheritance
Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public class SortField
Constructors
| Improve this Doc View SourceSortField(String, FieldCache.IParser)
Creates a sort by terms in the given field, parsed to numeric values using a custom FieldCache.IParser.
Declaration
public SortField(string field, FieldCache.IParser parser)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | Name of field to sort by. Must not be |
FieldCache.IParser | parser | Instance of a FieldCache.IParser, which must subclass one of the existing numeric parsers from IFieldCache. Sort type is inferred by testing which numeric parser the parser subclasses. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | if the parser fails to
subclass an existing numeric parser, or field is |
SortField(String, FieldCache.IParser, Boolean)
Creates a sort, possibly in reverse, by terms in the given field, parsed to numeric values using a custom FieldCache.IParser.
Declaration
public SortField(string field, FieldCache.IParser parser, bool reverse)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | Name of field to sort by. Must not be |
FieldCache.IParser | parser | Instance of a FieldCache.IParser, which must subclass one of the existing numeric parsers from IFieldCache. Sort type is inferred by testing which numeric parser the parser subclasses. |
System.Boolean | reverse |
|
Exceptions
Type | Condition |
---|---|
System.ArgumentException | if the parser fails to
subclass an existing numeric parser, or field is |
SortField(String, FieldComparerSource)
Creates a sort with a custom comparison function.
Declaration
public SortField(string field, FieldComparerSource comparer)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | Name of field to sort by; cannot be |
FieldComparerSource | comparer | Returns a comparer for sorting hits. |
SortField(String, FieldComparerSource, Boolean)
Creates a sort, possibly in reverse, with a custom comparison function.
Declaration
public SortField(string field, FieldComparerSource comparer, bool reverse)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | Name of field to sort by; cannot be |
FieldComparerSource | comparer | Returns a comparer for sorting hits. |
System.Boolean | reverse |
|
SortField(String, SortFieldType)
Creates a sort by terms in the given field with the type of term values explicitly given.
Declaration
public SortField(string field, SortFieldType type)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | Name of field to sort by. Can be |
SortFieldType | type | Type of values in the terms. |
SortField(String, SortFieldType, Boolean)
Creates a sort, possibly in reverse, by terms in the given field with the type of term values explicitly given.
Declaration
public SortField(string field, SortFieldType type, bool reverse)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | Name of field to sort by. Can be |
SortFieldType | type | Type of values in the terms. |
System.Boolean | reverse |
|
Fields
| Improve this Doc View SourceFIELD_DOC
Represents sorting by document number (index order).
Declaration
public static readonly SortField FIELD_DOC
Field Value
Type | Description |
---|---|
SortField |
FIELD_SCORE
Represents sorting by document score (relevance).
Declaration
public static readonly SortField FIELD_SCORE
Field Value
Type | Description |
---|---|
SortField |
m_missingValue
Declaration
protected object m_missingValue
Field Value
Type | Description |
---|---|
System.Object |
STRING_FIRST
Pass this to MissingValue to have missing string values sort first.
Declaration
public static readonly object STRING_FIRST
Field Value
Type | Description |
---|---|
System.Object |
STRING_LAST
Pass this to MissingValue to have missing string values sort last.
Declaration
public static readonly object STRING_LAST
Field Value
Type | Description |
---|---|
System.Object |
Properties
| Improve this Doc View SourceBytesComparer
Declaration
public virtual IComparer<BytesRef> BytesComparer { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IComparer<BytesRef> |
ComparerSource
Returns the FieldComparerSource used for custom sorting.
Declaration
public virtual FieldComparerSource ComparerSource { get; }
Property Value
Type | Description |
---|---|
FieldComparerSource |
Field
Declaration
public virtual string Field { get; }
Property Value
Type | Description |
---|---|
System.String | Name of field, possibly |
IsReverse
Returns whether the sort should be reversed.
Declaration
public virtual bool IsReverse { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
MissingValue
Declaration
public virtual object MissingValue { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
NeedsScores
Whether the relevance score is needed to sort documents.
Declaration
public virtual bool NeedsScores { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Parser
Returns the instance of a IFieldCache parser that fits to the given sort type.
May return null
if no parser was specified. Sorting is using the default parser then.
Declaration
public virtual FieldCache.IParser Parser { get; }
Property Value
Type | Description |
---|---|
FieldCache.IParser | An instance of a IFieldCache parser, or |
Type
Returns the type of contents in the field.
Declaration
public virtual SortFieldType Type { get; }
Property Value
Type | Description |
---|---|
SortFieldType |
Methods
| Improve this Doc View SourceEquals(Object)
Returns true
if o
is equal to this. If a
FieldComparerSource or
FieldCache.IParser was provided, it must properly
implement equals (unless a singleton is always used).
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
System.Object | o |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
GetComparer(Int32, Int32)
Returns the FieldComparer to use for sorting.
Declaration
public virtual FieldComparer GetComparer(int numHits, int sortPos)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | numHits | Number of top hits the queue will store |
System.Int32 | sortPos | Position of this SortField within Sort. The comparer is primary if sortPos==0, secondary if sortPos==1, etc. Some comparers can optimize themselves when they are the primary sort. |
Returns
Type | Description |
---|---|
FieldComparer | FieldComparer to use when sorting |
GetHashCode()
Returns a hash code value for this object. If a FieldComparerSource or FieldCache.IParser was provided, it must properly implement GetHashCode() (unless a singleton is always used).
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
Rewrite(IndexSearcher)
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 REWRITEABLE.
Declaration
public virtual SortField Rewrite(IndexSearcher searcher)
Parameters
Type | Name | Description |
---|---|---|
IndexSearcher | searcher | IndexSearcher to use during rewriting |
Returns
Type | Description |
---|---|
SortField | New rewritten SortField, or |
Exceptions
Type | Condition |
---|---|
System.IO.IOException | Can be thrown by the rewriting |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |