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

Loading...
Searching...
No Matches
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
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_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Query.h
Lucene::Collection
Utility template class to handle collections that can be safely copied and shared.
Definition Collection.h:17
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::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::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::ConstructQuery
void ConstructQuery(const QueryPtr &subQuery, Collection< ValueSourceQueryPtr > valSrcQueries)
Lucene::CustomScoreQuery::name
virtual String name()
A short name of this query, used in toString(String).
Lucene::CustomScoreQuery::equals
virtual bool equals(const LuceneObjectPtr &other)
Return whether two objects are equal.
Lucene::CustomScoreQuery::customExplain
virtual ExplanationPtr customExplain(int32_t doc, const ExplanationPtr &subQueryExpl, const ExplanationPtr &valSrcExpl)
Explain the custom score.
Lucene::CustomScoreQuery::setStrict
virtual void setStrict(bool strict)
Set the strict mode of this query.
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::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::subQuery
QueryPtr subQuery
Definition CustomScoreQuery.h:46
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::createWeight
virtual WeightPtr createWeight(const SearcherPtr &searcher)
Constructs an appropriate Weight implementation for this query. Only implemented by primitive queries...
Lucene::CustomScoreQuery::strict
bool strict
Definition CustomScoreQuery.h:48
Lucene::CustomScoreQuery::valSrcQueries
Collection< ValueSourceQueryPtr > valSrcQueries
Definition CustomScoreQuery.h:47
Lucene::CustomScoreQuery::CustomScorer
friend class CustomScorer
Definition CustomScoreQuery.h:127
Lucene::CustomScoreQuery::~CustomScoreQuery
virtual ~CustomScoreQuery()
Lucene::CustomScoreQuery::CustomWeight
friend class CustomWeight
Definition CustomScoreQuery.h:126
Lucene::CustomScoreQuery::clone
virtual LuceneObjectPtr clone(const LuceneObjectPtr &other=LuceneObjectPtr())
Returns a clone of this query.
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::hashCode
virtual int32_t hashCode()
Return hash code for this object.
Lucene::CustomScoreQuery::CustomScoreQuery
CustomScoreQuery(const QueryPtr &subQuery, Collection< ValueSourceQueryPtr > valSrcQueries)
Create a CustomScoreQuery over input subQuery and a ValueSourceQuery.
Lucene::CustomScoreQuery::getCustomScoreProvider
virtual CustomScoreProviderPtr getCustomScoreProvider(const IndexReaderPtr &reader)
Returns a CustomScoreProvider that calculates the custom scores for the given IndexReader....
Lucene::Query::Query
Query()
Lucene::Query::toString
virtual String toString(const String &field)
Prints a query to a string, with field assumed to be the default field and omitted.
Lucene
Definition AbstractAllTermDocs.h:12
Lucene::QueryPtr
boost::shared_ptr< Query > QueryPtr
Definition LuceneTypes.h:420
Lucene::WeightPtr
boost::shared_ptr< Weight > WeightPtr
Definition LuceneTypes.h:480
Lucene::ExplanationPtr
boost::shared_ptr< Explanation > ExplanationPtr
Definition LuceneTypes.h:333
Lucene::SearcherPtr
boost::shared_ptr< Searcher > SearcherPtr
Definition LuceneTypes.h:434
Lucene::ValueSourceQueryPtr
boost::shared_ptr< ValueSourceQuery > ValueSourceQueryPtr
Definition LuceneTypes.h:477
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition LuceneTypes.h:539
Lucene::CustomScoreProviderPtr
boost::shared_ptr< CustomScoreProvider > CustomScoreProviderPtr
Definition LuceneTypes.h:309
Lucene::IndexReaderPtr
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition LuceneTypes.h:157

clucene.sourceforge.net