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 
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);
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 
125 
126  friend class CustomWeight;
127  friend class CustomScorer;
128 };
129 
130 }
131 
132 #endif
Lucene::CustomScoreQuery::hashCode
virtual int32_t hashCode()
Return hash code for this object.
Lucene::CustomScoreQuery::name
virtual String name()
A short name of this query, used in toString(String).
Lucene::CustomScoreProviderPtr
boost::shared_ptr< CustomScoreProvider > CustomScoreProviderPtr
Definition: LuceneTypes.h:309
Lucene::CustomScoreQuery::ConstructQuery
void ConstructQuery(const QueryPtr &subQuery, Collection< ValueSourceQueryPtr > valSrcQueries)
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene::CustomScoreQuery::CustomScoreQuery
CustomScoreQuery(const QueryPtr &subQuery)
Create a CustomScoreQuery over input subQuery.
Lucene::CustomScoreQuery::customScore
virtual double customScore(int32_t doc, double subQueryScore, Collection< double > valSrcScores)
Compute a custom score by the subQuery score and a number of ValueSourceQuery scores.
Lucene::CustomScoreQuery::getCustomScoreProvider
virtual CustomScoreProviderPtr getCustomScoreProvider(const IndexReaderPtr &reader)
Returns a CustomScoreProvider that calculates the custom scores for the given {}. The default impleme...
Lucene::Collection< ValueSourceQueryPtr >
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
Lucene::CustomScoreQuery::customExplain
virtual ExplanationPtr customExplain(int32_t doc, const ExplanationPtr &subQueryExpl, const ExplanationPtr &valSrcExpl)
Explain the custom score.
Lucene::CustomScoreQuery::valSrcQueries
Collection< ValueSourceQueryPtr > valSrcQueries
Definition: CustomScoreQuery.h:47
Lucene::CustomScoreQuery::isStrict
virtual bool isStrict()
Checks if this is strict custom scoring. In strict custom scoring, the ValueSource part does not part...
Lucene::CustomScoreQuery::rewrite
virtual QueryPtr rewrite(const IndexReaderPtr &reader)
Called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into ...
Lucene::CustomScoreQuery::CustomScoreQuery
CustomScoreQuery(const QueryPtr &subQuery, Collection< ValueSourceQueryPtr > valSrcQueries)
Create a CustomScoreQuery over input subQuery and a ValueSourceQuery.
Lucene::QueryPtr
boost::shared_ptr< Query > QueryPtr
Definition: LuceneTypes.h:420
Query.h
Lucene::ValueSourceQueryPtr
boost::shared_ptr< ValueSourceQuery > ValueSourceQueryPtr
Definition: LuceneTypes.h:477
Lucene::CustomScoreQuery::createWeight
virtual WeightPtr createWeight(const SearcherPtr &searcher)
Constructs an appropriate Weight implementation for this query. Only implemented by primitive queries...
Lucene::CustomScoreQuery::CustomScoreQuery
CustomScoreQuery(const QueryPtr &subQuery, const ValueSourceQueryPtr &valSrcQuery)
Create a CustomScoreQuery over input subQuery and a ValueSourceQuery.
Lucene::CustomScoreQuery::customExplain
virtual ExplanationPtr customExplain(int32_t doc, const ExplanationPtr &subQueryExpl, Collection< ExplanationPtr > valSrcExpls)
Explain the custom score.
Lucene::CustomScoreQuery
Query that sets document score as a programmatic function of several (sub) scores:
Definition: CustomScoreQuery.h:21
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::WeightPtr
boost::shared_ptr< Weight > WeightPtr
Definition: LuceneTypes.h:480
Lucene::CustomScoreQuery::equals
virtual bool equals(const LuceneObjectPtr &other)
Return whether two objects are equal.
Lucene::IndexReaderPtr
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition: LuceneTypes.h:157
Lucene::CustomScoreQuery::clone
virtual LuceneObjectPtr clone(const LuceneObjectPtr &other=LuceneObjectPtr())
Returns a clone of this query.
Lucene::Query
The abstract base class for queries.
Definition: Query.h:31
Lucene::CustomScoreQuery::~CustomScoreQuery
virtual ~CustomScoreQuery()
Lucene::CustomScoreQuery::strict
bool strict
Definition: CustomScoreQuery.h:48
Lucene::CustomScoreQuery::customScore
virtual double customScore(int32_t doc, double subQueryScore, double valSrcScore)
Compute a custom score by the subQuery score and the ValueSourceQuery score.
Lucene::CustomScoreQuery::toString
virtual String toString(const String &field)
Prints a query to a string, with field assumed to be the default field and omitted.
Lucene::CustomScoreQuery::setStrict
virtual void setStrict(bool strict)
Set the strict mode of this query.
Lucene::ExplanationPtr
boost::shared_ptr< Explanation > ExplanationPtr
Definition: LuceneTypes.h:333
Lucene::CustomScoreQuery::subQuery
QueryPtr subQuery
Definition: CustomScoreQuery.h:43
Lucene::CustomScoreQuery::extractTerms
virtual void extractTerms(SetTerm terms)
Adds all terms occurring in this query to the terms set. Only works if this query is in its rewritten...
Lucene::Query::toString
virtual String toString()
Prints a query to a string.
Lucene::SearcherPtr
boost::shared_ptr< Searcher > SearcherPtr
Definition: LuceneTypes.h:434

clucene.sourceforge.net