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

CustomScoreQuery.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 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
43 LUCENE_CLASS(CustomScoreQuery);
44
45 protected:
46 QueryPtr subQuery;
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
Lucene::Query::toString
virtual String toString()
Prints a query to a string.
Lucene::ValueSourceQueryPtr
boost::shared_ptr< ValueSourceQuery > ValueSourceQueryPtr
Definition: LuceneTypes.h:477
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
Lucene::WeightPtr
boost::shared_ptr< Weight > WeightPtr
Definition: LuceneTypes.h:480
Lucene::SearcherPtr
boost::shared_ptr< Searcher > SearcherPtr
Definition: LuceneTypes.h:434
Lucene::CustomScoreQuery::subQuery
QueryPtr subQuery
Definition: CustomScoreQuery.h:43
Query.h
Lucene::CustomScoreQuery::strict
bool strict
Definition: CustomScoreQuery.h:48
Lucene::CustomScoreQuery::valSrcQueries
Collection< ValueSourceQueryPtr > valSrcQueries
Definition: CustomScoreQuery.h:47
Lucene::Query
The abstract base class for queries.
Definition: Query.h:31
Lucene::QueryPtr
boost::shared_ptr< Query > QueryPtr
Definition: LuceneTypes.h:420
Lucene::IndexReaderPtr
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition: LuceneTypes.h:157
Lucene::ExplanationPtr
boost::shared_ptr< Explanation > ExplanationPtr
Definition: LuceneTypes.h:333
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::Collection< ValueSourceQueryPtr >
Lucene::CustomScoreProviderPtr
boost::shared_ptr< CustomScoreProvider > CustomScoreProviderPtr
Definition: LuceneTypes.h:309
Lucene::CustomScoreQuery
Query that sets document score as a programmatic function of several (sub) scores: ...
Definition: CustomScoreQuery.h:21

clucene.sourceforge.net