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

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

MultiTermQuery.h
Go to the documentation of this file.
1 // 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 MULTITERMQUERY_H
8 #define MULTITERMQUERY_H
9
10 #include "Query.h"
11
12 namespace Lucene {
13
31 class LPPAPI MultiTermQuery : public Query {
32 public:
33 MultiTermQuery();
34 virtual ~MultiTermQuery();
35
36 LUCENE_CLASS(MultiTermQuery);
37
38 protected:
39 RewriteMethodPtr rewriteMethod;
40 int32_t numberOfTerms;
41
42 public:
50 static RewriteMethodPtr CONSTANT_SCORE_FILTER_REWRITE();
51
61 static RewriteMethodPtr SCORING_BOOLEAN_QUERY_REWRITE();
62
70 static RewriteMethodPtr CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE();
71
77 static RewriteMethodPtr CONSTANT_SCORE_AUTO_REWRITE_DEFAULT();
78
91 int32_t getTotalNumberOfTerms();
92
95 void clearTotalNumberOfTerms();
96
97 virtual QueryPtr rewrite(const IndexReaderPtr& reader);
98
100 virtual RewriteMethodPtr getRewriteMethod();
101
104 virtual void setRewriteMethod(const RewriteMethodPtr& method);
105
106 virtual LuceneObjectPtr clone(const LuceneObjectPtr& other = LuceneObjectPtr());
107 virtual int32_t hashCode();
108 virtual bool equals(const LuceneObjectPtr& other);
109
110 protected:
112 virtual FilteredTermEnumPtr getEnum(const IndexReaderPtr& reader) = 0;
113
114 void incTotalNumberOfTerms(int32_t inc);
115
116 friend class MultiTermQueryWrapperFilter;
117 friend class ScoringBooleanQueryRewrite;
118 friend class ConstantScoreAutoRewrite;
119 };
120
122 class LPPAPI RewriteMethod : public LuceneObject {
123 public:
124 virtual ~RewriteMethod();
125 LUCENE_CLASS(RewriteMethod);
126
127 public:
128 virtual QueryPtr rewrite(const IndexReaderPtr& reader, const MultiTermQueryPtr& query) = 0;
129 };
130
135 class LPPAPI ConstantScoreAutoRewrite : public RewriteMethod {
136 public:
137 ConstantScoreAutoRewrite();
138 virtual ~ConstantScoreAutoRewrite();
139
140 LUCENE_CLASS(ConstantScoreAutoRewrite);
141
142 public:
143 // Defaults derived from rough tests with a 20.0 million doc Wikipedia index. With more than 350 terms
144 // in the query, the filter method is fastest
145 static const int32_t DEFAULT_TERM_COUNT_CUTOFF;
146
147 // If the query will hit more than 1 in 1000 of the docs in the index (0.1%), the filter method is fastest
148 static const double DEFAULT_DOC_COUNT_PERCENT;
149
150 protected:
151 int32_t termCountCutoff;
152 double docCountPercent;
153
154 public:
157 virtual void setTermCountCutoff(int32_t count);
158
160 virtual int32_t getTermCountCutoff();
161
165 virtual void setDocCountPercent(double percent);
166
168 virtual double getDocCountPercent();
169
170 virtual QueryPtr rewrite(const IndexReaderPtr& reader, const MultiTermQueryPtr& query);
171
172 virtual int32_t hashCode();
173 virtual bool equals(const LuceneObjectPtr& other);
174 };
175
176 }
177
178 #endif
Lucene::MultiTermQueryPtr
boost::shared_ptr< MultiTermQuery > MultiTermQueryPtr
Definition: LuceneTypes.h:389
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
Lucene::ConstantScoreAutoRewrite::DEFAULT_DOC_COUNT_PERCENT
static const double DEFAULT_DOC_COUNT_PERCENT
Definition: MultiTermQuery.h:148
Lucene::MultiTermQuery
An abstract Query that matches documents containing a subset of terms provided by a FilteredTermEnum ...
Definition: MultiTermQuery.h:31
Query.h
Lucene::Query
The abstract base class for queries.
Definition: Query.h:31
Lucene::ConstantScoreAutoRewrite::docCountPercent
double docCountPercent
Definition: MultiTermQuery.h:152
Lucene::QueryPtr
boost::shared_ptr< Query > QueryPtr
Definition: LuceneTypes.h:420
Lucene::RewriteMethodPtr
boost::shared_ptr< RewriteMethod > RewriteMethodPtr
Definition: LuceneTypes.h:425
Lucene::RewriteMethod
Abstract class that defines how the query is rewritten.
Definition: MultiTermQuery.h:122
Lucene::IndexReaderPtr
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition: LuceneTypes.h:157
Lucene::ConstantScoreAutoRewrite::termCountCutoff
int32_t termCountCutoff
Definition: MultiTermQuery.h:151
Lucene::LuceneObject
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Lucene::MultiTermQuery::numberOfTerms
int32_t numberOfTerms
Definition: MultiTermQuery.h:40
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::FilteredTermEnumPtr
boost::shared_ptr< FilteredTermEnum > FilteredTermEnumPtr
Definition: LuceneTypes.h:365
Lucene::ConstantScoreAutoRewrite
A rewrite method that tries to pick the best constant-score rewrite method based on term and document...
Definition: MultiTermQuery.h:135
Lucene::MultiTermQueryWrapperFilter
A wrapper for MultiTermQuery, that exposes its functionality as a Filter.
Definition: MultiTermQueryWrapperFilter.h:22

clucene.sourceforge.net