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
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 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
clucene.sourceforge.net