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


 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CustomScoreQuery.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 CUSTOMSCOREQUERY_H
8 #define CUSTOMSCOREQUERY_H
9 
10 #include "Query.h"
11 
12 namespace Lucene {
13 
21 class LPPAPI CustomScoreQuery : public Query {
22 public:
25  CustomScoreQuery(const QueryPtr& subQuery);
26 
32  CustomScoreQuery(const QueryPtr& subQuery, const ValueSourceQueryPtr& valSrcQuery);
33 
39  CustomScoreQuery(const QueryPtr& subQuery, Collection<ValueSourceQueryPtr> valSrcQueries);
40 
41  virtual ~CustomScoreQuery();
42 
44 
45 protected:
47  Collection<ValueSourceQueryPtr> valSrcQueries; // never null (empty array if there are no valSrcQueries).
48  bool strict; // if true, valueSource part of query does not take part in weights normalization.
49 
50 public:
51  using Query::toString;
52 
53  virtual QueryPtr rewrite(const IndexReaderPtr& reader);
54  virtual void extractTerms(SetTerm terms);
55  virtual LuceneObjectPtr clone(const LuceneObjectPtr& other = LuceneObjectPtr());
56  virtual String toString(const String& field);
57  virtual bool equals(const LuceneObjectPtr& other);
58  virtual int32_t hashCode();
59 
68  virtual double customScore(int32_t doc, double subQueryScore, Collection<double> valSrcScores);
69 
78  virtual double customScore(int32_t doc, double subQueryScore, double valSrcScore);
79 
88  virtual ExplanationPtr customExplain(int32_t doc, const ExplanationPtr& subQueryExpl, Collection<ExplanationPtr> valSrcExpls);
89 
98  virtual ExplanationPtr customExplain(int32_t doc, const ExplanationPtr& subQueryExpl, const ExplanationPtr& valSrcExpl);
99 
100  virtual WeightPtr createWeight(const SearcherPtr& searcher);
101 
108  virtual bool isStrict();
109 
113  virtual void setStrict(bool strict);
114 
116  virtual String name();
117 
118 protected:
119  void ConstructQuery(const QueryPtr& subQuery, Collection<ValueSourceQueryPtr> valSrcQueries);
120 
124  virtual CustomScoreProviderPtr getCustomScoreProvider(const IndexReaderPtr& reader);
125 
126  friend class CustomWeight;
127  friend class CustomScorer;
128 };
129 
130 }
131 
132 #endif

clucene.sourceforge.net