Show / Hide Table of Contents

    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
    System.Object
    SortField
    Namespace: Lucene.Net.Search
    Assembly: Lucene.Net.dll
    Syntax
    public class SortField : object

    Constructors

    | Improve this Doc View Source

    SortField(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 null.

    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.

    | Improve this Doc View Source

    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 null.

    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

    True if natural order should be reversed.

    | Improve this Doc View Source

    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 null.

    FieldComparerSource comparer

    Returns a comparer for sorting hits.

    | Improve this Doc View Source

    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 null.

    FieldComparerSource comparer

    Returns a comparer for sorting hits.

    System.Boolean reverse

    True if natural order should be reversed.

    | Improve this Doc View Source

    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 null if type is SCORE or DOC.

    SortFieldType type

    Type of values in the terms.

    | Improve this Doc View Source

    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 null if type is SCORE or DOC.

    SortFieldType type

    Type of values in the terms.

    System.Boolean reverse

    True if natural order should be reversed.

    Fields

    | Improve this Doc View Source

    FIELD_DOC

    Represents sorting by document number (index order).

    Declaration
    public static readonly SortField FIELD_DOC
    Field Value
    Type Description
    SortField
    | Improve this Doc View Source

    FIELD_SCORE

    Represents sorting by document score (relevance).

    Declaration
    public static readonly SortField FIELD_SCORE
    Field Value
    Type Description
    SortField
    | Improve this Doc View Source

    m_missingValue

    Declaration
    protected object m_missingValue
    Field Value
    Type Description
    System.Object
    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    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 Source

    BytesComparer

    Declaration
    public virtual IComparer<BytesRef> BytesComparer { get; set; }
    Property Value
    Type Description
    IComparer<BytesRef>
    | Improve this Doc View Source

    ComparerSource

    Returns the FieldComparerSource used for custom sorting.

    Declaration
    public virtual FieldComparerSource ComparerSource { get; }
    Property Value
    Type Description
    FieldComparerSource
    | Improve this Doc View Source

    Field

    Returns the name of the field. Could return null if the sort is by SCORE or DOC.

    Declaration
    public virtual string Field { get; }
    Property Value
    Type Description
    System.String

    Name of field, possibly null.

    | Improve this Doc View Source

    IsReverse

    Returns whether the sort should be reversed.

    Declaration
    public virtual bool IsReverse { get; }
    Property Value
    Type Description
    System.Boolean

    True if natural order should be reversed.

    | Improve this Doc View Source

    MissingValue

    Declaration
    public virtual object MissingValue { get; set; }
    Property Value
    Type Description
    System.Object
    | Improve this Doc View Source

    NeedsScores

    Whether the relevance score is needed to sort documents.

    Declaration
    public virtual bool NeedsScores { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    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 null.

    | Improve this Doc View Source

    Type

    Returns the type of contents in the field.

    Declaration
    public virtual SortFieldType Type { get; }
    Property Value
    Type Description
    SortFieldType

    One of SCORE, DOC, STRING, INT32 or SINGLE.

    Methods

    | Improve this Doc View Source

    Equals(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
    | Improve this Doc View Source

    GetComparer(Int32, Int32)

    Returns the FieldComparer to use for sorting.

    This is a Lucene.NET EXPERIMENTAL API, use at your own risk
    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

    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    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.

    This is a Lucene.NET EXPERIMENTAL API, use at your own risk
    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 this if nothing has changed.

    | Improve this Doc View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    See Also

    Sort
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)