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


lucene::search::SortComparator Class Reference

Abstract base class for sorting hits returned by a Query. More...

#include <Sort.h>

Inheritance diagram for lucene::search::SortComparator:

lucene::search::SortComparatorSource

Public Member Functions

virtual ScoreDocComparatornewComparator (lucene::index::IndexReader *reader, const TCHAR *fieldname)
 Creates a comparator for the field in the given index.
 SortComparator ()
virtual ~SortComparator ()
virtual lucene::util::ComparablegetComparable (const TCHAR *termtext)=0
 Returns an object which, when sorted according to natural order, will order the Term values in the correct order.

Detailed Description

Abstract base class for sorting hits returned by a Query.

This class should only be used if the other SortField types (SCORE, DOC, STRING, INT, FLOAT) do not provide an adequate sorting. It maintains an internal cache of values which could be quite large. The cache is an array of Comparable, one for each document in the index. There is a distinct Comparable for each unique term in the field - if some documents have the same term in the field, the cache array will have entries which reference the same Comparable.


Constructor & Destructor Documentation

lucene::search::SortComparator::SortComparator (  ) 

virtual lucene::search::SortComparator::~SortComparator (  )  [virtual]


Member Function Documentation

virtual ScoreDocComparator* lucene::search::SortComparator::newComparator ( lucene::index::IndexReader reader,
const TCHAR *  fieldname 
) [virtual]

Creates a comparator for the field in the given index.

Parameters:
reader Index to create comparator for.
fieldname Field to create comparator for.
Returns:
Comparator of ScoreDoc objects.
Exceptions:
IOException If an error occurs reading the index.

Implements lucene::search::SortComparatorSource.

virtual lucene:: util ::Comparable* lucene::search::SortComparator::getComparable ( const TCHAR *  termtext  )  [pure virtual]

Returns an object which, when sorted according to natural order, will order the Term values in the correct order.

For example, if the Terms contained integer values, this method would return new Integer(termtext). Note that this might not always be the most efficient implementation - for this particular example, a better implementation might be to make a ScoreDocLookupComparator that uses an internal lookup table of int.

Parameters:
termtext The textual value of the term.
Returns:
An object representing termtext that sorts according to the natural order of termtext.
See also:
Comparable

ScoreDocComparator


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

clucene.sourceforge.net