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


 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
MultiTermQuery.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 MULTITERMQUERY_H
8 #define MULTITERMQUERY_H
9 
10 #include "Query.h"
11 
12 namespace Lucene {
13 
31 class LPPAPI MultiTermQuery : public Query {
32 public:
34  virtual ~MultiTermQuery();
35 
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 
117  friend class ScoringBooleanQueryRewrite;
119 };
120 
122 class LPPAPI RewriteMethod : public LuceneObject {
123 public:
124  virtual ~RewriteMethod();
126 
127 public:
128  virtual QueryPtr rewrite(const IndexReaderPtr& reader, const MultiTermQueryPtr& query) = 0;
129 };
130 
136 public:
138  virtual ~ConstantScoreAutoRewrite();
139 
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:
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

clucene.sourceforge.net