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 // Copyright (c) 2009-2011 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  {
33  public:
35  virtual ~MultiTermQuery();
36 
38 
39  protected:
40  RewriteMethodPtr rewriteMethod;
41  int32_t numberOfTerms;
42 
43  public:
51  static RewriteMethodPtr CONSTANT_SCORE_FILTER_REWRITE();
52 
62  static RewriteMethodPtr SCORING_BOOLEAN_QUERY_REWRITE();
63 
71  static RewriteMethodPtr CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE();
72 
78  static RewriteMethodPtr CONSTANT_SCORE_AUTO_REWRITE_DEFAULT();
79 
92  int32_t getTotalNumberOfTerms();
93 
96  void clearTotalNumberOfTerms();
97 
98  virtual QueryPtr rewrite(IndexReaderPtr reader);
99 
101  virtual RewriteMethodPtr getRewriteMethod();
102 
105  virtual void setRewriteMethod(RewriteMethodPtr method);
106 
107  virtual LuceneObjectPtr clone(LuceneObjectPtr other = LuceneObjectPtr());
108  virtual int32_t hashCode();
109  virtual bool equals(LuceneObjectPtr other);
110 
111  protected:
113  virtual FilteredTermEnumPtr getEnum(IndexReaderPtr reader) = 0;
114 
115  void incTotalNumberOfTerms(int32_t inc);
116 
118  friend class ScoringBooleanQueryRewrite;
120  };
121 
123  class LPPAPI RewriteMethod : public LuceneObject
124  {
125  public:
126  virtual ~RewriteMethod();
128 
129  public:
130  virtual QueryPtr rewrite(IndexReaderPtr reader, MultiTermQueryPtr query) = 0;
131  };
132 
138  {
139  public:
141  virtual ~ConstantScoreAutoRewrite();
142 
144 
145  public:
146  // Defaults derived from rough tests with a 20.0 million doc Wikipedia index. With more than 350 terms
147  // in the query, the filter method is fastest
148  static const int32_t DEFAULT_TERM_COUNT_CUTOFF;
149 
150  // If the query will hit more than 1 in 1000 of the docs in the index (0.1%), the filter method is fastest
151  static const double DEFAULT_DOC_COUNT_PERCENT;
152 
153  protected:
156 
157  public:
160  virtual void setTermCountCutoff(int32_t count);
161 
163  virtual int32_t getTermCountCutoff();
164 
168  virtual void setDocCountPercent(double percent);
169 
171  virtual double getDocCountPercent();
172 
173  virtual QueryPtr rewrite(IndexReaderPtr reader, MultiTermQueryPtr query);
174 
175  virtual int32_t hashCode();
176  virtual bool equals(LuceneObjectPtr other);
177  };
178 }
179 
180 #endif

clucene.sourceforge.net