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

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. More...
| 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. More...
| 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. More...
| SortField (const String &field, const FieldComparatorSourcePtr &comparator, bool reverse=false)
| Creates a sort, possibly in reverse, with a custom comparison function. More...
virtual | ~SortField ()
virtual String | getClassName ()
boost::shared_ptr< SortField > | shared_from_this ()
String | getField ()
| Returns the name of the field. Could return null if the sort is by SCORE or DOC. More...
int32_t | getType ()
| Returns the type of contents in the field. More...
localePtr | getLocale ()
| Returns the Locale by which term values are interpreted. More...
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. More...
bool | getReverse ()
| Returns whether the sort should be reversed. More...
FieldComparatorSourcePtr | getComparatorSource ()
| Returns the FieldComparatorSource used for custom sorting. More...
virtual String | toString ()
| Returns a string representation of the object. More...
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). More...
virtual int32_t | hashCode ()
| Return hash code for this object. More...
FieldComparatorPtr | getComparator (int32_t numHits, int32_t sortPos)
| Returns the FieldComparator to use for sorting. More...
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. More...
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr())
| Return clone of this object. More...
virtual int32_t | compareTo (const LuceneObjectPtr &other)
| Compare two objects. More...
Public Member Functions inherited from Lucene::LuceneSync
virtual | ~LuceneSync ()
virtual SynchronizePtr | getSync ()
| Return this object synchronize lock. More...
virtual LuceneSignalPtr | getSignal ()
| Return this object signal. More...
virtual void | lock (int32_t timeout=0)
| Lock this object using an optional timeout. More...
virtual void | unlock ()
| Unlock this object. More...
virtual bool | holdsLock ()
| Returns true if this object is currently locked by current thread. More...
virtual void | wait (int32_t timeout=0)
| Wait for signal using an optional timeout. More...
virtual void | notifyAll ()
| Notify all threads waiting for signal. More...

## Static Public Member Functions

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

## Data Fields

INTERNAL | __pad0__: 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. More...
static const int32_t | DOC
| Sort by document number (index order). Sort values are Integer and lower values are at the front. More...
static const int32_t | STRING
| Sort using term values as Strings. Sort values are String and lower values are at the front. More...
static const int32_t | INT
| Sort using term values as Integers. Sort values are Integer and lower values are at the front. More...
static const int32_t | FLOAT
| Sort using term values as Floats. Sort values are Float and lower values are at the front. More...
static const int32_t | LONG
| Sort using term values as Longs. Sort values are Long and lower values are at the front. More...
static const int32_t | DOUBLE
| Sort using term values as Doubles. Sort values are Double and lower values are at the front. More...
static const int32_t | SHORT
| Sort using term values as Shorts. Sort values are Short and lower values are at the front. More...
static const int32_t | CUSTOM
| Sort using a custom Comparator. Sort values are any ComparableValue and sorting is done according to natural order. More...
static const int32_t | BYTE
| Sort using term values as Bytes. Sort values are Byte and lower values are at the front. More...
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. More...

## 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. More...
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

  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() [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

  field | Name of field to sort by
  parser | Instance 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.
  reverse | True 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

  field | Name of field to sort by, cannot be null.
  locale | Locale of values in the field.
  reverse | True 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

  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.

## ◆ ~SortField()

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

virtual

## Member Function Documentation

## ◆ _getClassName()

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

inline static

## ◆ 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 | ( |  | ) |

inline virtual

## ◆ getComparator()

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

Returns the FieldComparator to use for sorting.

Parameters

  numHits | number of top hits the queue will store
  sortPos | 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.

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:

- SortField.h

clucene.sourceforge.net