summaryrefslogtreecommitdiff
path: root/src/mongo/db/fts/fts_matcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/fts/fts_matcher.cpp')
-rw-r--r--src/mongo/db/fts/fts_matcher.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/mongo/db/fts/fts_matcher.cpp b/src/mongo/db/fts/fts_matcher.cpp
index 544ef93cf36..52c67e337e9 100644
--- a/src/mongo/db/fts/fts_matcher.cpp
+++ b/src/mongo/db/fts/fts_matcher.cpp
@@ -31,9 +31,9 @@
#include "mongo/platform/basic.h"
#include "mongo/db/fts/fts_matcher.h"
+#include "mongo/db/fts/fts_phrase_matcher.h"
#include "mongo/db/fts/fts_tokenizer.h"
#include "mongo/db/fts/fts_element_iterator.h"
-#include "mongo/platform/strcasestr.h"
namespace mongo {
@@ -41,17 +41,6 @@ namespace fts {
using std::string;
-/**
- * Does the string 'phrase' occur in the string 'haystack'? Match is case-insensitive if
- * 'caseSensitive' is false; otherwise, an exact substring match is performed.
- */
-static bool phraseMatches(const string& phrase, const string& haystack, bool caseSensitive) {
- if (caseSensitive) {
- return haystack.find(phrase) != string::npos;
- }
- return strcasestr(haystack.c_str(), phrase.c_str()) != NULL;
-}
-
FTSMatcher::FTSMatcher(const FTSQuery& query, const FTSSpec& spec) : _query(query), _spec(spec) {}
bool FTSMatcher::matches(const BSONObj& obj) const {
@@ -163,7 +152,12 @@ bool FTSMatcher::_phraseMatch(const string& phrase, const BSONObj& obj) const {
while (it.more()) {
FTSIteratorValue val = it.next();
- if (phraseMatches(phrase, val._text, _query.getCaseSensitive())) {
+
+ if (val._language->getPhraseMatcher().phraseMatches(phrase,
+ val._text,
+ _query.getCaseSensitive()
+ ? FTSPhraseMatcher::kCaseSensitive
+ : FTSPhraseMatcher::kNone)) {
return true;
}
}