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

Loading...
Searching...
No Matches
SortField.h
Go to the documentation of this file.
1
2// Copyright (c) 2009-2014 Alan Wright. All rights reserved.
3// Distributable under the terms of either the Apache License (Version 2.0)
4// or the GNU Lesser General Public License.
6
7#ifndef SORTFIELD_H
8#define SORTFIELD_H
9
10#include "LuceneObject.h"
11
12 namespace Lucene {
13
16 class LPPAPI SortField : public LuceneObject {
17 public:
22 SortField(const String& field, int32_t type, bool reverse = false);
23
30 SortField(const String& field, const ParserPtr& parser, bool reverse = false);
31
36 SortField(const String& field, const std::locale& locale, bool reverse = false);
37
42 SortField(const String& field, const FieldComparatorSourcePtr& comparator, bool reverse = false);
43
44 virtual ~SortField();
45
46 LUCENE_CLASS(SortField);
47
48 public:
50 static const int32_t SCORE;
51
53 static const int32_t DOC;
54
56 static const int32_t STRING;
57
59 static const int32_t INT;
60
62 static const int32_t FLOAT;
63
65 static const int32_t LONG;
66
68 static const int32_t DOUBLE;
69
71 static const int32_t SHORT;
72
75 static const int32_t CUSTOM;
76
78 static const int32_t BYTE;
79
82 static const int32_t STRING_VAL;
83
84INTERNAL:
85 bool reverse; // defaults to natural order
86
87 String field;
88 int32_t type; // defaults to determining type dynamically
89 localePtr locale; // defaults to "natural order" (no Locale)
90 ParserPtr parser;
91
92 private:
94 FieldComparatorSourcePtr comparatorSource;
95
96 public:
98 static SortFieldPtr FIELD_SCORE();
99
101 static SortFieldPtr FIELD_DOC();
102
105 String getField();
106
109 int32_t getType();
110
112 localePtr getLocale();
113
117 ParserPtr getParser();
118
121 bool getReverse();
122
124 FieldComparatorSourcePtr getComparatorSource();
125
126 virtual String toString();
127
130 virtual bool equals(const LuceneObjectPtr& other);
131
132 virtual int32_t hashCode();
133
139 FieldComparatorPtr getComparator(int32_t numHits, int32_t sortPos);
140
141 protected:
143 void initFieldType(const String& field, int32_t type);
144};
145
146}
147
148#endif
LuceneObject.h
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Lucene::LuceneObject::LuceneObject
LuceneObject()
Lucene::SortField::getType
int32_t getType()
Returns the type of contents in the field.
Lucene::SortField::FLOAT
static const int32_t FLOAT
Sort using term values as Floats. Sort values are Float and lower values are at the front.
Definition SortField.h:62
Lucene::SortField::equals
virtual bool equals(const LuceneObjectPtr &other)
Returns true if other is equal to this. If a FieldComparatorSource or Parser was provided,...
Lucene::SortField::parser
ParserPtr parser
Definition SortField.h:90
Lucene::SortField::DOC
static const int32_t DOC
Sort by document number (index order). Sort values are Integer and lower values are at the front.
Definition SortField.h:53
Lucene::SortField::hashCode
virtual int32_t hashCode()
Return hash code for this object.
Lucene::SortField::STRING
static const int32_t STRING
Sort using term values as Strings. Sort values are String and lower values are at the front.
Definition SortField.h:56
Lucene::SortField::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...
Lucene::SortField::initFieldType
void initFieldType(const String &field, int32_t type)
Sets field and type, and ensures field is not NULL unless type is SCORE or DOC.
Lucene::SortField::SortField
SortField(const String &field, const FieldComparatorSourcePtr &comparator, bool reverse=false)
Creates a sort, possibly in reverse, with a custom comparison function.
Lucene::SortField::getParser
ParserPtr getParser()
Returns the instance of a FieldCache parser that fits to the given sort type. May return null if no p...
Lucene::SortField::toString
virtual String toString()
Returns a string representation of the object.
Lucene::SortField::locale
localePtr locale
Definition SortField.h:89
Lucene::SortField::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.
Lucene::SortField::STRING_VAL
static const int32_t STRING_VAL
Sort using term values as Strings, but comparing by value (using String::compare) for all comparisons...
Definition SortField.h:82
Lucene::SortField::INT
static const int32_t INT
Sort using term values as Integers. Sort values are Integer and lower values are at the front.
Definition SortField.h:59
Lucene::SortField::SCORE
static const int32_t SCORE
Sort by document score (relevancy). Sort values are Double and higher values are at the front.
Definition SortField.h:50
Lucene::SortField::getReverse
bool getReverse()
Returns whether the sort should be reversed.
Lucene::SortField::LONG
static const int32_t LONG
Sort using term values as Longs. Sort values are Long and lower values are at the front.
Definition SortField.h:65
Lucene::SortField::BYTE
static const int32_t BYTE
Sort using term values as Bytes. Sort values are Byte and lower values are at the front.
Definition SortField.h:78
Lucene::SortField::getComparatorSource
FieldComparatorSourcePtr getComparatorSource()
Returns the FieldComparatorSource used for custom sorting.
Lucene::SortField::field
String field
Definition SortField.h:87
Lucene::SortField::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 cu...
Lucene::SortField::getLocale
localePtr getLocale()
Returns the Locale by which term values are interpreted.
Lucene::SortField::type
int32_t type
Definition SortField.h:88
Lucene::SortField::getComparator
FieldComparatorPtr getComparator(int32_t numHits, int32_t sortPos)
Returns the FieldComparator to use for sorting.
Lucene::SortField::~SortField
virtual ~SortField()
Lucene::SortField::CUSTOM
static const int32_t CUSTOM
Sort using a custom Comparator. Sort values are any ComparableValue and sorting is done according to ...
Definition SortField.h:75
Lucene::SortField::FIELD_SCORE
static SortFieldPtr FIELD_SCORE()
Represents sorting by document score (relevancy).
Lucene::SortField::SHORT
static const int32_t SHORT
Sort using term values as Shorts. Sort values are Short and lower values are at the front.
Definition SortField.h:71
Lucene::SortField::FIELD_DOC
static SortFieldPtr FIELD_DOC()
Represents sorting by document number (index order).
Lucene::SortField::DOUBLE
static const int32_t DOUBLE
Sort using term values as Doubles. Sort values are Double and lower values are at the front.
Definition SortField.h:68
Lucene::SortField::getField
String getField()
Returns the name of the field. Could return null if the sort is by SCORE or DOC.
Lucene
Definition AbstractAllTermDocs.h:12
Lucene::FieldComparatorSourcePtr
boost::shared_ptr< FieldComparatorSource > FieldComparatorSourcePtr
Definition LuceneTypes.h:349
Lucene::FieldComparatorPtr
boost::shared_ptr< FieldComparator > FieldComparatorPtr
Definition LuceneTypes.h:348
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition LuceneTypes.h:539
Lucene::SortFieldPtr
boost::shared_ptr< SortField > SortFieldPtr
Definition LuceneTypes.h:443
Lucene::ParserPtr
boost::shared_ptr< Parser > ParserPtr
Definition LuceneTypes.h:401

clucene.sourceforge.net