Lucene++ - a full-featured, c++ search engine
API Documentation


Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes | Protected Member Functions
Lucene::SortField Class Reference

Stores information about how to sort documents by terms in an individual field. Fields must be indexed in order to sort by them. More...

#include <SortField.h>

+ Inheritance diagram for Lucene::SortField:

Public Member Functions

 SortField (const String &field, int32_t type, bool reverse=false)
 Creates a sort by terms in the given field with the type of term values explicitly given.
 
 SortField (const String &field, const ParserPtr &parser, bool reverse=false)
 Creates a sort, possibly in reverse, by terms in the given field, parsed to numeric values using a custom Parser.
 
 SortField (const String &field, const std::locale &locale, bool reverse=false)
 Creates a sort, possibly in reverse, by terms in the given field sorted according to the given locale.
 
 SortField (const String &field, const FieldComparatorSourcePtr &comparator, bool reverse=false)
 Creates a sort, possibly in reverse, with a custom comparison function.
 
virtual ~SortField ()
 
virtual String getClassName ()
 
boost::shared_ptr< SortFieldshared_from_this ()
 
String getField ()
 Returns the name of the field. Could return null if the sort is by SCORE or DOC.
 
int32_t getType ()
 Returns the type of contents in the field.
 
localePtr getLocale ()
 Returns the Locale by which term values are interpreted.
 
ParserPtr getParser ()
 Returns the instance of a FieldCache parser that fits to the given sort type. May return null if no parser was specified. Sorting is using the default parser then.
 
bool getReverse ()
 Returns whether the sort should be reversed.
 
FieldComparatorSourcePtr getComparatorSource ()
 Returns the FieldComparatorSource used for custom sorting.
 
virtual String toString ()
 Returns a string representation of the object.
 
virtual bool equals (const LuceneObjectPtr &other)
 Returns true if other is equal to this. If a FieldComparatorSource or Parser was provided, it must properly implement equals (unless a singleton is always used).
 
virtual int32_t hashCode ()
 Return hash code for this object.
 
FieldComparatorPtr getComparator (int32_t numHits, int32_t sortPos)
 Returns the FieldComparator to use for sorting.
 
- Public Member Functions inherited from Lucene::LuceneObject
virtual ~LuceneObject ()
 
virtual void initialize ()
 Called directly after instantiation to create objects that depend on this object being fully constructed.
 
virtual LuceneObjectPtr clone (const LuceneObjectPtr &other=LuceneObjectPtr())
 Return clone of this object.
 
virtual int32_t compareTo (const LuceneObjectPtr &other)
 Compare two objects.
 
- Public Member Functions inherited from Lucene::LuceneSync
virtual ~LuceneSync ()
 
virtual SynchronizePtr getSync ()
 Return this object synchronize lock.
 
virtual LuceneSignalPtr getSignal ()
 Return this object signal.
 
virtual void lock (int32_t timeout=0)
 Lock this object using an optional timeout.
 
virtual void unlock ()
 Unlock this object.
 
virtual bool holdsLock ()
 Returns true if this object is currently locked by current thread.
 
virtual void wait (int32_t timeout=0)
 Wait for signal using an optional timeout.
 
virtual void notifyAll ()
 Notify all threads waiting for signal.
 

Static Public Member Functions

static String _getClassName ()
 
static SortFieldPtr FIELD_SCORE ()
 Represents sorting by document score (relevancy).
 
static SortFieldPtr FIELD_DOC ()
 Represents sorting by document number (index order).
 

Data Fields

INTERNAL : bool reverse
 
String field
 
int32_t type
 
localePtr locale
 
ParserPtr parser
 

Static Public Attributes

static const int32_t SCORE
 Sort by document score (relevancy). Sort values are Double and higher values are at the front.
 
static const int32_t DOC
 Sort by document number (index order). Sort values are Integer and lower values are at the front.
 
static const int32_t STRING
 Sort using term values as Strings. Sort values are String and lower values are at the front.
 
static const int32_t INT
 Sort using term values as Integers. Sort values are Integer and lower values are at the front.
 
static const int32_t FLOAT
 Sort using term values as Floats. Sort values are Float and lower values are at the front.
 
static const int32_t LONG
 Sort using term values as Longs. Sort values are Long and lower values are at the front.
 
static const int32_t DOUBLE
 Sort using term values as Doubles. Sort values are Double and lower values are at the front.
 
static const int32_t SHORT
 Sort using term values as Shorts. Sort values are Short and lower values are at the front.
 
static const int32_t CUSTOM
 Sort using a custom Comparator. Sort values are any ComparableValue and sorting is done according to natural order.
 
static const int32_t BYTE
 Sort using term values as Bytes. Sort values are Byte and lower values are at the front.
 
static const int32_t STRING_VAL
 Sort using term values as Strings, but comparing by value (using String::compare) for all comparisons. This is typically slower than STRING, which uses ordinals to do the sorting.
 

Protected Member Functions

void initFieldType (const String &field, int32_t type)
 Sets field and type, and ensures field is not NULL unless type is SCORE or DOC.
 
- Protected Member Functions inherited from Lucene::LuceneObject
 LuceneObject ()
 

Additional Inherited Members

- Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr objectLock
 
LuceneSignalPtr objectSignal
 

Detailed Description

Stores information about how to sort documents by terms in an individual field. Fields must be indexed in order to sort by them.

Constructor & Destructor Documentation

◆ SortField() [1/4]

Lucene::SortField::SortField ( const String &  field,
int32_t  type,
bool  reverse = false 
)

Creates a sort by terms in the given field with the type of term values explicitly given.

Parameters
fieldName of field to sort by. Can be null if type is SCORE or DOC.
typeType of values in the terms.
reverseTrue if natural order should be reversed.

◆ SortField() [2/4]

Lucene::SortField::SortField ( const String &  field,
const ParserPtr parser,
bool  reverse = false 
)

Creates a sort, possibly in reverse, by terms in the given field, parsed to numeric values using a custom Parser.

Parameters
fieldName of field to sort by
parserInstance of a Parser, which must subclass one of the existing numeric parsers from FieldCache. Sort type is inferred by testing which numeric parser the parser subclasses.
reverseTrue if natural order should be reversed.

◆ SortField() [3/4]

Lucene::SortField::SortField ( const String &  field,
const std::locale &  locale,
bool  reverse = false 
)

Creates a sort, possibly in reverse, by terms in the given field sorted according to the given locale.

Parameters
fieldName of field to sort by, cannot be null.
localeLocale of values in the field.
reverseTrue if natural order should be reversed.

◆ SortField() [4/4]

Lucene::SortField::SortField ( const String &  field,
const FieldComparatorSourcePtr comparator,
bool  reverse = false 
)

Creates a sort, possibly in reverse, with a custom comparison function.

Parameters
fieldName of field to sort by; cannot be null.
comparatorReturns a comparator for sorting hits.
reverseTrue if natural order should be reversed.

◆ ~SortField()

virtual Lucene::SortField::~SortField ( )
virtual

Member Function Documentation

◆ _getClassName()

static String Lucene::SortField::_getClassName ( )
inlinestatic

◆ equals()

virtual bool Lucene::SortField::equals ( const LuceneObjectPtr other)
virtual

Returns true if other is equal to this. If a FieldComparatorSource or Parser was provided, it must properly implement equals (unless a singleton is always used).

Reimplemented from Lucene::LuceneObject.

◆ FIELD_DOC()

static SortFieldPtr Lucene::SortField::FIELD_DOC ( )
static

Represents sorting by document number (index order).

◆ FIELD_SCORE()

static SortFieldPtr Lucene::SortField::FIELD_SCORE ( )
static

Represents sorting by document score (relevancy).

◆ getClassName()

virtual String Lucene::SortField::getClassName ( )
inlinevirtual

◆ getComparator()

FieldComparatorPtr Lucene::SortField::getComparator ( int32_t  numHits,
int32_t  sortPos 
)

Returns the FieldComparator to use for sorting.

Parameters
numHitsnumber of top hits the queue will store
sortPosposition 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.
Returns
FieldComparator to use when sorting

◆ getComparatorSource()

FieldComparatorSourcePtr Lucene::SortField::getComparatorSource ( )

Returns the FieldComparatorSource used for custom sorting.

◆ getField()

String Lucene::SortField::getField ( )

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

Returns
Name of field, possibly null.

◆ getLocale()

localePtr Lucene::SortField::getLocale ( )

Returns the Locale by which term values are interpreted.

◆ getParser()

ParserPtr Lucene::SortField::getParser ( )

Returns the instance of a FieldCache parser that fits to the given sort type. May return null if no parser was specified. Sorting is using the default parser then.

Returns
An instance of a parser, or null.

◆ getReverse()

bool Lucene::SortField::getReverse ( )

Returns whether the sort should be reversed.

Returns
True if natural order should be reversed.

◆ getType()

int32_t Lucene::SortField::getType ( )

Returns the type of contents in the field.

Returns
One of the constants SCORE, DOC, STRING, INT or DOUBLE.

◆ hashCode()

virtual int32_t Lucene::SortField::hashCode ( )
virtual

Return hash code for this object.

Reimplemented from Lucene::LuceneObject.

◆ initFieldType()

void Lucene::SortField::initFieldType ( const String &  field,
int32_t  type 
)
protected

Sets field and type, and ensures field is not NULL unless type is SCORE or DOC.

◆ shared_from_this()

boost::shared_ptr< SortField > Lucene::SortField::shared_from_this ( )
inline

◆ toString()

virtual String Lucene::SortField::toString ( )
virtual

Returns a string representation of the object.

Reimplemented from Lucene::LuceneObject.

Field Documentation

◆ __pad0__

INTERNAL Lucene::SortField::__pad0__

◆ BYTE

const int32_t Lucene::SortField::BYTE
static

Sort using term values as Bytes. Sort values are Byte and lower values are at the front.

◆ CUSTOM

const int32_t Lucene::SortField::CUSTOM
static

Sort using a custom Comparator. Sort values are any ComparableValue and sorting is done according to natural order.

◆ DOC

const int32_t Lucene::SortField::DOC
static

Sort by document number (index order). Sort values are Integer and lower values are at the front.

◆ DOUBLE

const int32_t Lucene::SortField::DOUBLE
static

Sort using term values as Doubles. Sort values are Double and lower values are at the front.

◆ field

String Lucene::SortField::field

◆ FLOAT

const int32_t Lucene::SortField::FLOAT
static

Sort using term values as Floats. Sort values are Float and lower values are at the front.

◆ INT

const int32_t Lucene::SortField::INT
static

Sort using term values as Integers. Sort values are Integer and lower values are at the front.

◆ locale

localePtr Lucene::SortField::locale

◆ LONG

const int32_t Lucene::SortField::LONG
static

Sort using term values as Longs. Sort values are Long and lower values are at the front.

◆ parser

ParserPtr Lucene::SortField::parser

◆ SCORE

const int32_t Lucene::SortField::SCORE
static

Sort by document score (relevancy). Sort values are Double and higher values are at the front.

◆ SHORT

const int32_t Lucene::SortField::SHORT
static

Sort using term values as Shorts. Sort values are Short and lower values are at the front.

◆ STRING

const int32_t Lucene::SortField::STRING
static

Sort using term values as Strings. Sort values are String and lower values are at the front.

◆ STRING_VAL

const int32_t Lucene::SortField::STRING_VAL
static

Sort using term values as Strings, but comparing by value (using String::compare) for all comparisons. This is typically slower than STRING, which uses ordinals to do the sorting.

◆ type

int32_t Lucene::SortField::type

The documentation for this class was generated from the following file:

clucene.sourceforge.net