summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_text_base.cpp
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2015-11-18 17:31:32 -0500
committerJason Rassi <rassi@10gen.com>2015-11-18 17:38:27 -0500
commit23136883e394b73cbc26f873cd0276779adef3df (patch)
treeb53259aeeaeb8a7e7450796dec662157d9b0a44d /src/mongo/db/matcher/expression_text_base.cpp
parent7bac6c8f64019082f205c7606c65f173972960a3 (diff)
downloadmongo-23136883e394b73cbc26f873cd0276779adef3df.tar.gz
SERVER-19510 Move text query parsing to TextMatchExpression::init()
- Introduces FTSQuery, which is now the base class for FTSQueryImpl. - Introduces a derived class FTSQueryNoop (which TextNoOpMatchExpression now wraps). libfts_query_noop is now linked into db/matcher/expressions. - TextMatchExpression now parses the text query (which acquires a collection lock as part of the parsing process), and TextNode now stores a parsed version of the query. The FTSQuery::parse() call in buildStages() is removed. Behavior change: $text against a non-existent collection now returns an error, instead of an empty result set.
Diffstat (limited to 'src/mongo/db/matcher/expression_text_base.cpp')
-rw-r--r--src/mongo/db/matcher/expression_text_base.cpp36
1 files changed, 12 insertions, 24 deletions
diff --git a/src/mongo/db/matcher/expression_text_base.cpp b/src/mongo/db/matcher/expression_text_base.cpp
index 04b62ecd6b1..82fa7f9fd3e 100644
--- a/src/mongo/db/matcher/expression_text_base.cpp
+++ b/src/mongo/db/matcher/expression_text_base.cpp
@@ -30,23 +30,21 @@
#include "mongo/db/matcher/expression_text_base.h"
+#include "mongo/db/fts/fts_query.h"
+
namespace mongo {
const bool TextMatchExpressionBase::kCaseSensitiveDefault = false;
const bool TextMatchExpressionBase::kDiacriticSensitiveDefault = false;
-TextMatchExpressionBase::TextMatchExpressionBase(TextParams params)
- : LeafMatchExpression(TEXT),
- _query(std::move(params.query)),
- _language(std::move(params.language)),
- _caseSensitive(params.caseSensitive),
- _diacriticSensitive(params.diacriticSensitive) {}
+TextMatchExpressionBase::TextMatchExpressionBase() : LeafMatchExpression(TEXT) {}
void TextMatchExpressionBase::debugString(StringBuilder& debug, int level) const {
+ const fts::FTSQuery& ftsQuery = getFTSQuery();
_debugAddSpace(debug, level);
- debug << "TEXT : query=" << _query << ", language=" << _language
- << ", caseSensitive=" << _caseSensitive << ", diacriticSensitive=" << _diacriticSensitive
- << ", tag=";
+ debug << "TEXT : query=" << ftsQuery.getQuery() << ", language=" << ftsQuery.getLanguage()
+ << ", caseSensitive=" << ftsQuery.getCaseSensitive()
+ << ", diacriticSensitive=" << ftsQuery.getDiacriticSensitive() << ", tag=";
MatchExpression::TagData* td = getTag();
if (NULL != td) {
td->debugString(&debug);
@@ -57,9 +55,11 @@ void TextMatchExpressionBase::debugString(StringBuilder& debug, int level) const
}
void TextMatchExpressionBase::toBSON(BSONObjBuilder* out) const {
+ const fts::FTSQuery& ftsQuery = getFTSQuery();
out->append("$text",
- BSON("$search" << _query << "$language" << _language << "$caseSensitive"
- << _caseSensitive << "$diacriticSensitive" << _diacriticSensitive));
+ BSON("$search" << ftsQuery.getQuery() << "$language" << ftsQuery.getLanguage()
+ << "$caseSensitive" << ftsQuery.getCaseSensitive()
+ << "$diacriticSensitive" << ftsQuery.getDiacriticSensitive()));
}
bool TextMatchExpressionBase::equivalent(const MatchExpression* other) const {
@@ -68,19 +68,7 @@ bool TextMatchExpressionBase::equivalent(const MatchExpression* other) const {
}
const TextMatchExpressionBase* realOther = static_cast<const TextMatchExpressionBase*>(other);
- if (realOther->getQuery() != _query) {
- return false;
- }
- if (realOther->getLanguage() != _language) {
- return false;
- }
- if (realOther->getCaseSensitive() != _caseSensitive) {
- return false;
- }
- if (realOther->getDiacriticSensitive() != _diacriticSensitive) {
- return false;
- }
- return true;
+ return getFTSQuery().equivalent(realOther->getFTSQuery());
}
} // namespace mongo