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


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:
34 
35  virtual ~BooleanScorer2();
36 
38 
39 protected:
43 
45 
48 
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);
68  ScorerPtr dualConjunctionSumScorer(const ScorerPtr& req1, const ScorerPtr& req2);
69 
75 
79  ScorerPtr addProhibitedScorers(const ScorerPtr& requiredCountingSumScorer);
80 
83 };
84 
85 class Coordinator : public LuceneObject {
86 public:
87  Coordinator(const BooleanScorer2Ptr& scorer);
88  virtual ~Coordinator();
89 
91 
92 public:
93  BooleanScorer2WeakPtr _scorer;
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 
111 
112 protected:
113  ScorerPtr scorer;
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 
126 public:
127  CountingDisjunctionSumScorer(const BooleanScorer2Ptr& scorer, Collection<ScorerPtr> subScorers, int32_t minimumNrMatchers);
128  virtual ~CountingDisjunctionSumScorer();
129 
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 
146 public:
148  virtual ~CountingConjunctionSumScorer();
149 
151 
152 protected:
153  BooleanScorer2WeakPtr _scorer;
154  int32_t lastScoredDoc;
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
Scorer for conjunctions, sets of queries, all of which are required.
Definition: ConjunctionScorer.h:15
friend class CountingDisjunctionSumScorer
Definition: BooleanScorer2.h:81
double lastDocScore
Definition: BooleanScorer2.h:137
Definition: BooleanScorer2.h:85
virtual void initialize()
Called directly after instantiation to create objects that depend on this object being fully construc...
Collection< ScorerPtr > prohibitedScorers
Definition: BooleanScorer2.h:42
boost::weak_ptr< BooleanScorer2 > BooleanScorer2WeakPtr
Definition: LuceneTypes.h:282
SimilarityPtr similarity
Definition: Scorer.h:29
ScorerPtr makeCountingSumScorerSomeReq()
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...
int32_t lastScoredDoc
Definition: BooleanScorer2.h:134
double lastDocScore
Definition: BooleanScorer2.h:158
ScorerPtr makeCountingSumScorer()
Returns the scorer to be used for match counting and score summing. Uses requiredScorers, optionalScorers and prohibitedScorers.
int32_t maxCoord
Definition: BooleanScorer2.h:95
virtual int32_t docID()
Returns the following:
boost::shared_ptr< Scorer > ScorerPtr
Definition: LuceneTypes.h:429
int32_t minNrShouldMatch
Definition: BooleanScorer2.h:49
See the description in BooleanScorer, comparing BooleanScorer & BooleanScorer2.
Definition: BooleanScorer2.h:20
CoordinatorPtr coordinator
Definition: BooleanScorer2.h:114
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...
virtual int32_t advance(int32_t target)
Advances to the first beyond the current whose document number is greater than or equal to target...
ScorerPtr countingConjunctionSumScorer(Collection< ScorerPtr > requiredScorers)
boost::shared_ptr< Coordinator > CoordinatorPtr
Definition: LuceneTypes.h:305
Definition: BooleanScorer2.h:125
Common scoring functionality for different types of queries.
Definition: Scorer.h:22
boost::shared_ptr< Collector > CollectorPtr
Definition: LuceneTypes.h:295
Definition: BooleanScorer2.h:145
double lastDocScore
Definition: BooleanScorer2.h:116
int32_t lastScoredDoc
Definition: BooleanScorer2.h:154
virtual double score()
Returns the score of the current document matching the query. Initially invalid, until nextDoc() or a...
Base class for all Lucene classes.
Definition: LuceneObject.h:31
boost::shared_ptr< BooleanScorer2 > BooleanScorer2Ptr
Definition: LuceneTypes.h:282
int32_t lastScoredDoc
Definition: BooleanScorer2.h:115
Collection< ScorerPtr > requiredScorers
Definition: BooleanScorer2.h:37
Collection< ScorerPtr > optionalScorers
Definition: BooleanScorer2.h:41
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Definition: AbstractAllTermDocs.h:12
ScorerPtr makeCountingSumScorerNoReq()
ScorerPtr dualConjunctionSumScorer(const ScorerPtr &req1, const ScorerPtr &req2)
A Scorer for OR like queries, counterpart of ConjunctionScorer. This Scorer implements Scorer#skipTo(...
Definition: DisjunctionSumScorer.h:16
Collection< double > coordFactors
Definition: BooleanScorer2.h:94
ScorerPtr addProhibitedScorers(const ScorerPtr &requiredCountingSumScorer)
Returns the scorer to be used for match counting and score summing. Uses the given required scorer an...
CoordinatorPtr coordinator
Definition: BooleanScorer2.h:44
int32_t nrMatchers
Definition: BooleanScorer2.h:96
friend class CountingConjunctionSumScorer
Definition: BooleanScorer2.h:82
boost::shared_ptr< Similarity > SimilarityPtr
Definition: LuceneTypes.h:435
ScorerPtr countingDisjunctionSumScorer(Collection< ScorerPtr > scorers, int32_t minNrShouldMatch)
ScorerPtr countingSumScorer
The scorer to which all scoring will be delegated, except for computing and using the coordination fa...
Definition: BooleanScorer2.h:47
Count a scorer as a single match.
Definition: BooleanScorer2.h:105
int32_t doc
Definition: BooleanScorer2.h:50
int32_t requiredNrMatchers
Definition: BooleanScorer2.h:155

clucene.sourceforge.net