Lucene++ - a full-featured, c++ search engine
API Documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
include
BooleanScorer2.h
Go to the documentation of this file.
1
// Copyright (c) 2009-2011 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
{
22
public
:
34
BooleanScorer2
(
SimilarityPtr
similarity
, int32_t
minNrShouldMatch
,
Collection<ScorerPtr>
required,
Collection<ScorerPtr>
prohibited,
Collection<ScorerPtr>
optional);
35
36
virtual
~BooleanScorer2
();
37
38
LUCENE_CLASS
(
BooleanScorer2
);
39
40
protected
:
41
Collection<ScorerPtr>
requiredScorers
;
42
Collection<ScorerPtr>
optionalScorers
;
43
Collection<ScorerPtr>
prohibitedScorers
;
44
45
CoordinatorPtr
coordinator
;
46
48
ScorerPtr
countingSumScorer
;
49
50
int32_t
minNrShouldMatch
;
51
int32_t
doc
;
52
53
public
:
54
virtual
void
initialize
();
55
58
virtual
void
score
(
CollectorPtr
collector);
59
60
virtual
bool
score
(
CollectorPtr
collector, int32_t max, int32_t firstDocID);
61
virtual
int32_t
docID
();
62
virtual
int32_t
nextDoc
();
63
virtual
double
score
();
64
virtual
int32_t
advance
(int32_t target);
65
66
protected
:
67
ScorerPtr
countingDisjunctionSumScorer
(
Collection<ScorerPtr>
scorers, int32_t minNrShouldMatch);
68
ScorerPtr
countingConjunctionSumScorer
(
Collection<ScorerPtr>
requiredScorers
);
69
ScorerPtr
dualConjunctionSumScorer
(
ScorerPtr
req1,
ScorerPtr
req2);
70
73
ScorerPtr
makeCountingSumScorer
();
74
ScorerPtr
makeCountingSumScorerNoReq
();
75
ScorerPtr
makeCountingSumScorerSomeReq
();
76
80
ScorerPtr
addProhibitedScorers
(
ScorerPtr
requiredCountingSumScorer);
81
82
friend
class
CountingDisjunctionSumScorer
;
83
friend
class
CountingConjunctionSumScorer
;
84
};
85
86
class
Coordinator
:
public
LuceneObject
87
{
88
public
:
89
Coordinator
(
BooleanScorer2Ptr
scorer);
90
virtual
~Coordinator
();
91
92
LUCENE_CLASS
(
Coordinator
);
93
94
public
:
95
BooleanScorer2WeakPtr
_scorer
;
96
Collection<double>
coordFactors
;
97
int32_t
maxCoord
;
// to be increased for each non prohibited scorer
98
int32_t
nrMatchers
;
// to be increased by score() of match counting scorers.
99
100
public
:
101
void
init
();
// use after all scorers have been added.
102
103
friend
class
BooleanScorer2
;
104
};
105
107
class
SingleMatchScorer
:
public
Scorer
108
{
109
public
:
110
SingleMatchScorer
(
ScorerPtr
scorer
,
CoordinatorPtr
coordinator
);
111
virtual
~SingleMatchScorer
();
112
113
LUCENE_CLASS
(
SingleMatchScorer
);
114
115
protected
:
116
ScorerPtr
scorer
;
117
CoordinatorPtr
coordinator
;
118
int32_t
lastScoredDoc
;
119
double
lastDocScore
;
120
121
public
:
122
virtual
double
score
();
123
virtual
int32_t
docID
();
124
virtual
int32_t
nextDoc
();
125
virtual
int32_t
advance
(int32_t target);
126
};
127
128
class
CountingDisjunctionSumScorer
:
public
DisjunctionSumScorer
129
{
130
public
:
131
CountingDisjunctionSumScorer
(
BooleanScorer2Ptr
scorer,
Collection<ScorerPtr>
subScorers
, int32_t
minimumNrMatchers
);
132
virtual
~CountingDisjunctionSumScorer
();
133
134
LUCENE_CLASS
(
CountingDisjunctionSumScorer
);
135
136
protected
:
137
BooleanScorer2WeakPtr
_scorer
;
138
int32_t
lastScoredDoc
;
139
140
// Save the score of lastScoredDoc, so that we don't compute it more than once in score().
141
double
lastDocScore
;
142
143
public
:
144
virtual
double
score
();
145
146
friend
class
BooleanScorer2
;
147
};
148
149
class
CountingConjunctionSumScorer
:
public
ConjunctionScorer
150
{
151
public
:
152
CountingConjunctionSumScorer
(
BooleanScorer2Ptr
scorer,
SimilarityPtr
similarity
,
Collection<ScorerPtr>
scorers
);
153
virtual
~CountingConjunctionSumScorer
();
154
155
LUCENE_CLASS
(
CountingConjunctionSumScorer
);
156
157
protected
:
158
BooleanScorer2WeakPtr
_scorer
;
159
int32_t
lastScoredDoc
;
160
int32_t
requiredNrMatchers
;
161
162
// Save the score of lastScoredDoc, so that we don't compute it more than once in score().
163
double
lastDocScore
;
164
165
public
:
166
virtual
double
score
();
167
};
168
}
169
170
#endif
clucene.sourceforge.net