4
* Copyright (C) 2012 10gen Inc.
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Affero General Public License, version 3,
8
* as published by the Free Software Foundation.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Affero General Public License for more details.
15
* You should have received a copy of the GNU Affero General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
26
#include "mongo/base/disallow_copying.h"
27
#include "mongo/db/fts/fts_index.h"
28
#include "mongo/db/fts/fts_matcher.h"
29
#include "mongo/db/fts/fts_query.h"
30
#include "mongo/db/fts/fts_util.h"
31
#include "mongo/db/matcher.h"
39
// priority queue template, for use when we're populating results
40
// vector returned to the user. extends the default priority_queue
41
// by providing direct access to the underlying vector, which should
42
// be used CAREFULLY because you can get into trouble..
43
template <class T, class S, class C>
44
class a_priority_queue : public std::priority_queue<T, S, C> {
46
// return the value of an element at position n when we call pq[n]
47
T operator[](const int &n) { return this->c[n]; }
48
// return underlying data structure. called dangerous because it is.
49
S dangerous() { return this->c; }
52
typedef a_priority_queue<ScoredLocation, vector<ScoredLocation>, ScoredLocationComp> Results;
55
MONGO_DISALLOW_COPYING(FTSSearch);
58
typedef std::map<Record*,double> Scores;
60
FTSSearch( NamespaceDetails* ns,
61
const IndexDetails& id,
62
const BSONObj& indexPrefix,
63
const FTSQuery& query,
64
const BSONObj& filter );
67
void go(Results* results, unsigned limit );
69
const FTSIndex * getIndex() const { return _fts; }
71
long long getKeysLookedAt() const { return _keysLookedAt; }
72
long long getObjLookedAt() const { return _objectsLookedAt; }
76
void _process( BtreeCursor* cursor );
79
* checks not index pieces
80
* i.e. prhases & negated terms
82
bool _ok( Record* record ) const;
84
NamespaceDetails* _ns;
85
const IndexDetails& _id;
89
FTSMatcher _ftsMatcher;
91
scoped_ptr<CoveredIndexMatcher> _matcher;
93
long long _keysLookedAt;
94
long long _objectsLookedAt;