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

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

BooleanScorer2.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 BOOLEANSCORER2_H
8 #define BOOLEANSCORER2_H
9
10 #include "DisjunctionSumScorer.h"
11 #include "ConjunctionScorer.h"
12
13 namespace Lucene {
14
20 class BooleanScorer2 : public Scorer {
21 public:
33 BooleanScorer2(const SimilarityPtr& similarity, int32_t minNrShouldMatch, Collection<ScorerPtr> required, Collection<ScorerPtr> prohibited, Collection<ScorerPtr> optional);
34
35 virtual ~BooleanScorer2();
36
37 LUCENE_CLASS(BooleanScorer2);
38
39 protected:
40 Collection<ScorerPtr> requiredScorers;
41 Collection<ScorerPtr> optionalScorers;
42 Collection<ScorerPtr> prohibitedScorers;
43
44 CoordinatorPtr coordinator;
45
47 ScorerPtr countingSumScorer;
48
49 int32_t minNrShouldMatch;
50 int32_t doc;
51
52 public:
53 virtual void initialize();
54
57 virtual void score(const CollectorPtr& collector);
58
59 virtual bool score(const CollectorPtr& collector, int32_t max, int32_t firstDocID);
60 virtual int32_t docID();
61 virtual int32_t nextDoc();
62 virtual double score();
63 virtual int32_t advance(int32_t target);
64
65 protected:
66 ScorerPtr countingDisjunctionSumScorer(Collection<ScorerPtr> scorers, int32_t minNrShouldMatch);
67 ScorerPtr countingConjunctionSumScorer(Collection<ScorerPtr> requiredScorers);
68 ScorerPtr dualConjunctionSumScorer(const ScorerPtr& req1, const ScorerPtr& req2);
69
72 ScorerPtr makeCountingSumScorer();
73 ScorerPtr makeCountingSumScorerNoReq();
74 ScorerPtr makeCountingSumScorerSomeReq();
75
79 ScorerPtr addProhibitedScorers(const ScorerPtr& requiredCountingSumScorer);
80
81 friend class CountingDisjunctionSumScorer;
82 friend class CountingConjunctionSumScorer;
83 };
84
85 class Coordinator : public LuceneObject {
86 public:
87 Coordinator(const BooleanScorer2Ptr& scorer);
88 virtual ~Coordinator();
89
90 LUCENE_CLASS(Coordinator);
91
92 public:
93 BooleanScorer2WeakPtr _scorer;
94 Collection<double> coordFactors;
95 int32_t maxCoord; // to be increased for each non prohibited scorer
96 int32_t nrMatchers; // to be increased by score() of match counting scorers.
97
98 public:
99 void init(); // use after all scorers have been added.
100
101 friend class BooleanScorer2;
102 };
103
105 class SingleMatchScorer : public Scorer {
106 public:
107 SingleMatchScorer(const ScorerPtr& scorer, const CoordinatorPtr& coordinator);
108 virtual ~SingleMatchScorer();
109
110 LUCENE_CLASS(SingleMatchScorer);
111
112 protected:
113 ScorerPtr scorer;
114 CoordinatorPtr coordinator;
115 int32_t lastScoredDoc;
116 double lastDocScore;
117
118 public:
119 virtual double score();
120 virtual int32_t docID();
121 virtual int32_t nextDoc();
122 virtual int32_t advance(int32_t target);
123 };
124
125 class CountingDisjunctionSumScorer : public DisjunctionSumScorer {
126 public:
127 CountingDisjunctionSumScorer(const BooleanScorer2Ptr& scorer, Collection<ScorerPtr> subScorers, int32_t minimumNrMatchers);
128 virtual ~CountingDisjunctionSumScorer();
129
130 LUCENE_CLASS(CountingDisjunctionSumScorer);
131
132 protected:
133 BooleanScorer2WeakPtr _scorer;
134 int32_t lastScoredDoc;
135
136 // Save the score of lastScoredDoc, so that we don't compute it more than once in score().
137 double lastDocScore;
138
139 public:
140 virtual double score();
141
142 friend class BooleanScorer2;
143 };
144
145 class CountingConjunctionSumScorer : public ConjunctionScorer {
146 public:
147 CountingConjunctionSumScorer(const BooleanScorer2Ptr& scorer, const SimilarityPtr& similarity, Collection<ScorerPtr> scorers);
148 virtual ~CountingConjunctionSumScorer();
149
150 LUCENE_CLASS(CountingConjunctionSumScorer);
151
152 protected:
153 BooleanScorer2WeakPtr _scorer;
154 int32_t lastScoredDoc;
155 int32_t requiredNrMatchers;
156
157 // Save the score of lastScoredDoc, so that we don't compute it more than once in score().
158 double lastDocScore;
159
160 public:
161 virtual double score();
162 };
163
164 }
165
166 #endif
Lucene::SingleMatchScorer::nextDoc
virtual int32_t nextDoc()
Advances to the next document in the set and returns the doc it is currently on, or NO_MORE_DOCS if t...
Lucene::ConjunctionScorer
Scorer for conjunctions, sets of queries, all of which are required.
Definition: ConjunctionScorer.h:15
Lucene::CountingDisjunctionSumScorer::lastDocScore
double lastDocScore
Definition: BooleanScorer2.h:137
Lucene::Coordinator
Definition: BooleanScorer2.h:85
Lucene::Coordinator::init
void init()
Lucene::BooleanScorer2::initialize
virtual void initialize()
Called directly after instantiation to create objects that depend on this object being fully construc...
Lucene::BooleanScorer2::prohibitedScorers
Collection< ScorerPtr > prohibitedScorers
Definition: BooleanScorer2.h:42
Lucene::SingleMatchScorer::scorer
ScorerPtr scorer
Definition: BooleanScorer2.h:110
Lucene::BooleanScorer2WeakPtr
boost::weak_ptr< BooleanScorer2 > BooleanScorer2WeakPtr
Definition: LuceneTypes.h:282
Lucene::SingleMatchScorer::score
virtual double score()
Returns the score of the current document matching the query. Initially invalid, until nextDoc() or a...
Lucene::Coordinator::_scorer
BooleanScorer2WeakPtr _scorer
Definition: BooleanScorer2.h:90
Lucene::CountingDisjunctionSumScorer::_scorer
BooleanScorer2WeakPtr _scorer
Definition: BooleanScorer2.h:130
Lucene::Scorer::similarity
SimilarityPtr similarity
Definition: Scorer.h:29
Lucene::BooleanScorer2::makeCountingSumScorerSomeReq
ScorerPtr makeCountingSumScorerSomeReq()
Lucene::BooleanScorer2::nextDoc
virtual int32_t nextDoc()
Advances to the next document in the set and returns the doc it is currently on, or NO_MORE_DOCS if t...
Lucene::CountingDisjunctionSumScorer::lastScoredDoc
int32_t lastScoredDoc
Definition: BooleanScorer2.h:134
Lucene::SingleMatchScorer::docID
virtual int32_t docID()
Returns the following:
Lucene::CountingConjunctionSumScorer::lastDocScore
double lastDocScore
Definition: BooleanScorer2.h:158
Lucene::CountingDisjunctionSumScorer::score
virtual double score()
Returns the score of the current document matching the query. Initially invalid, until next() is call...
Lucene::BooleanScorer2::makeCountingSumScorer
ScorerPtr makeCountingSumScorer()
Returns the scorer to be used for match counting and score summing. Uses requiredScorers, optionalScorers and prohibitedScorers.
Lucene::Coordinator::maxCoord
int32_t maxCoord
Definition: BooleanScorer2.h:95
Lucene::BooleanScorer2::docID
virtual int32_t docID()
Returns the following:
Lucene::BooleanScorer2::~BooleanScorer2
virtual ~BooleanScorer2()
Lucene::ScorerPtr
boost::shared_ptr< Scorer > ScorerPtr
Definition: LuceneTypes.h:429
Lucene::BooleanScorer2::minNrShouldMatch
int32_t minNrShouldMatch
Definition: BooleanScorer2.h:49
ConjunctionScorer.h
Lucene::BooleanScorer2
See the description in BooleanScorer, comparing BooleanScorer & BooleanScorer2.
Definition: BooleanScorer2.h:20
Lucene::SingleMatchScorer::coordinator
CoordinatorPtr coordinator
Definition: BooleanScorer2.h:114
Lucene::BooleanScorer2::BooleanScorer2
BooleanScorer2(const SimilarityPtr &similarity, int32_t minNrShouldMatch, Collection< ScorerPtr > required, Collection< ScorerPtr > prohibited, Collection< ScorerPtr > optional)
Creates a Scorer with the given similarity and lists of required, prohibited and optional scorers...
Lucene::BooleanScorer2::advance
virtual int32_t advance(int32_t target)
Advances to the first beyond the current whose document number is greater than or equal to target...
Lucene::BooleanScorer2::countingConjunctionSumScorer
ScorerPtr countingConjunctionSumScorer(Collection< ScorerPtr > requiredScorers)
Lucene::Coordinator::~Coordinator
virtual ~Coordinator()
Lucene::SingleMatchScorer::SingleMatchScorer
SingleMatchScorer(const ScorerPtr &scorer, const CoordinatorPtr &coordinator)
Lucene::DisjunctionSumScorer::minimumNrMatchers
int32_t minimumNrMatchers
The minimum number of scorers that should match.
Definition: DisjunctionSumScorer.h:31
Lucene::CoordinatorPtr
boost::shared_ptr< Coordinator > CoordinatorPtr
Definition: LuceneTypes.h:305
Lucene::CountingDisjunctionSumScorer
Definition: BooleanScorer2.h:125
Lucene::Scorer
Common scoring functionality for different types of queries.
Definition: Scorer.h:22
Lucene::CollectorPtr
boost::shared_ptr< Collector > CollectorPtr
Definition: LuceneTypes.h:295
Lucene::CountingDisjunctionSumScorer::CountingDisjunctionSumScorer
CountingDisjunctionSumScorer(const BooleanScorer2Ptr &scorer, Collection< ScorerPtr > subScorers, int32_t minimumNrMatchers)
Lucene::CountingConjunctionSumScorer
Definition: BooleanScorer2.h:145
Lucene::SingleMatchScorer::~SingleMatchScorer
virtual ~SingleMatchScorer()
Lucene::SingleMatchScorer::lastDocScore
double lastDocScore
Definition: BooleanScorer2.h:116
Lucene::CountingConjunctionSumScorer::lastScoredDoc
int32_t lastScoredDoc
Definition: BooleanScorer2.h:154
Lucene::CountingConjunctionSumScorer::_scorer
BooleanScorer2WeakPtr _scorer
Definition: BooleanScorer2.h:150
Lucene::BooleanScorer2::score
virtual double score()
Returns the score of the current document matching the query. Initially invalid, until nextDoc() or a...
Lucene::LuceneObject
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Lucene::BooleanScorer2Ptr
boost::shared_ptr< BooleanScorer2 > BooleanScorer2Ptr
Definition: LuceneTypes.h:282
Lucene::Coordinator::Coordinator
Coordinator(const BooleanScorer2Ptr &scorer)
DisjunctionSumScorer.h
Lucene::SingleMatchScorer::lastScoredDoc
int32_t lastScoredDoc
Definition: BooleanScorer2.h:115
Lucene::BooleanScorer2::requiredScorers
Collection< ScorerPtr > requiredScorers
Definition: BooleanScorer2.h:37
Lucene::BooleanScorer2::optionalScorers
Collection< ScorerPtr > optionalScorers
Definition: BooleanScorer2.h:41
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::BooleanScorer2::makeCountingSumScorerNoReq
ScorerPtr makeCountingSumScorerNoReq()
Lucene::CountingConjunctionSumScorer::~CountingConjunctionSumScorer
virtual ~CountingConjunctionSumScorer()
Lucene::ConjunctionScorer::scorers
Collection< ScorerPtr > scorers
Definition: ConjunctionScorer.h:20
Lucene::BooleanScorer2::dualConjunctionSumScorer
ScorerPtr dualConjunctionSumScorer(const ScorerPtr &req1, const ScorerPtr &req2)
Lucene::DisjunctionSumScorer
A Scorer for OR like queries, counterpart of ConjunctionScorer. This Scorer implements Scorer#skipTo(...
Definition: DisjunctionSumScorer.h:16
Lucene::Coordinator::coordFactors
Collection< double > coordFactors
Definition: BooleanScorer2.h:94
Lucene::BooleanScorer2::addProhibitedScorers
ScorerPtr addProhibitedScorers(const ScorerPtr &requiredCountingSumScorer)
Returns the scorer to be used for match counting and score summing. Uses the given required scorer an...
Lucene::CountingConjunctionSumScorer::score
virtual double score()
Returns the score of the current document matching the query. Initially invalid, until nextDoc() or a...
Lucene::Collection< ScorerPtr >
Lucene::BooleanScorer2::coordinator
CoordinatorPtr coordinator
Definition: BooleanScorer2.h:44
Lucene::Coordinator::nrMatchers
int32_t nrMatchers
Definition: BooleanScorer2.h:96
Lucene::DisjunctionSumScorer::subScorers
Collection< ScorerPtr > subScorers
The subscorers.
Definition: DisjunctionSumScorer.h:28
Lucene::SingleMatchScorer::advance
virtual int32_t advance(int32_t target)
Advances to the first beyond the current whose document number is greater than or equal to target...
Lucene::SimilarityPtr
boost::shared_ptr< Similarity > SimilarityPtr
Definition: LuceneTypes.h:435
Lucene::CountingConjunctionSumScorer::CountingConjunctionSumScorer
CountingConjunctionSumScorer(const BooleanScorer2Ptr &scorer, const SimilarityPtr &similarity, Collection< ScorerPtr > scorers)
Lucene::BooleanScorer2::countingDisjunctionSumScorer
ScorerPtr countingDisjunctionSumScorer(Collection< ScorerPtr > scorers, int32_t minNrShouldMatch)
Lucene::BooleanScorer2::countingSumScorer
ScorerPtr countingSumScorer
The scorer to which all scoring will be delegated, except for computing and using the coordination fa...
Definition: BooleanScorer2.h:47
Lucene::SingleMatchScorer
Count a scorer as a single match.
Definition: BooleanScorer2.h:105
Lucene::BooleanScorer2::doc
int32_t doc
Definition: BooleanScorer2.h:50
Lucene::CountingConjunctionSumScorer::requiredNrMatchers
int32_t requiredNrMatchers
Definition: BooleanScorer2.h:155
Lucene::CountingDisjunctionSumScorer::~CountingDisjunctionSumScorer
virtual ~CountingDisjunctionSumScorer()

clucene.sourceforge.net