summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/matcher/expression_text.cpp')
-rw-r--r--src/mongo/db/matcher/expression_text.cpp111
1 files changed, 53 insertions, 58 deletions
diff --git a/src/mongo/db/matcher/expression_text.cpp b/src/mongo/db/matcher/expression_text.cpp
index 320136c8751..e1f1ccd065f 100644
--- a/src/mongo/db/matcher/expression_text.cpp
+++ b/src/mongo/db/matcher/expression_text.cpp
@@ -33,72 +33,67 @@
namespace mongo {
- using std::string;
+using std::string;
- Status TextMatchExpression::init( const string& query,
- const string& language,
- bool caseSensitive ) {
- _query = query;
- _language = language;
- _caseSensitive = caseSensitive;
- return initPath( "_fts" );
- }
-
- bool TextMatchExpression::matchesSingleElement( const BSONElement& e ) const {
- // See ops/update.cpp.
- // This node is removed by the query planner. It's only ever called if we're getting an
- // elemMatchKey.
- return true;
- }
+Status TextMatchExpression::init(const string& query, const string& language, bool caseSensitive) {
+ _query = query;
+ _language = language;
+ _caseSensitive = caseSensitive;
+ return initPath("_fts");
+}
- void TextMatchExpression::debugString( StringBuilder& debug, int level ) const {
- _debugAddSpace(debug, level);
- debug << "TEXT : query=" << _query << ", language="
- << _language << ", caseSensitive="
- << _caseSensitive << ", tag=";
- MatchExpression::TagData* td = getTag();
- if ( NULL != td ) {
- td->debugString( &debug );
- }
- else {
- debug << "NULL";
- }
- debug << "\n";
- }
+bool TextMatchExpression::matchesSingleElement(const BSONElement& e) const {
+ // See ops/update.cpp.
+ // This node is removed by the query planner. It's only ever called if we're getting an
+ // elemMatchKey.
+ return true;
+}
- void TextMatchExpression::toBSON(BSONObjBuilder* out) const {
- out->append("$text", BSON("$search" << _query <<
- "$language" << _language <<
- "$caseSensitive" << _caseSensitive));
+void TextMatchExpression::debugString(StringBuilder& debug, int level) const {
+ _debugAddSpace(debug, level);
+ debug << "TEXT : query=" << _query << ", language=" << _language
+ << ", caseSensitive=" << _caseSensitive << ", tag=";
+ MatchExpression::TagData* td = getTag();
+ if (NULL != td) {
+ td->debugString(&debug);
+ } else {
+ debug << "NULL";
}
+ debug << "\n";
+}
- bool TextMatchExpression::equivalent( const MatchExpression* other ) const {
- if ( matchType() != other->matchType() ) {
- return false;
- }
- const TextMatchExpression* realOther = static_cast<const TextMatchExpression*>( other );
+void TextMatchExpression::toBSON(BSONObjBuilder* out) const {
+ out->append("$text",
+ BSON("$search" << _query << "$language" << _language << "$caseSensitive"
+ << _caseSensitive));
+}
- // TODO This is way too crude. It looks for string equality, but it should be looking for
- // common parsed form
- if ( realOther->getQuery() != _query ) {
- return false;
- }
- if ( realOther->getLanguage() != _language ) {
- return false;
- }
- if ( realOther->getCaseSensitive() != _caseSensitive ) {
- return false;
- }
- return true;
+bool TextMatchExpression::equivalent(const MatchExpression* other) const {
+ if (matchType() != other->matchType()) {
+ return false;
}
+ const TextMatchExpression* realOther = static_cast<const TextMatchExpression*>(other);
- LeafMatchExpression* TextMatchExpression::shallowClone() const {
- TextMatchExpression* next = new TextMatchExpression();
- next->init( _query, _language, _caseSensitive );
- if ( getTag() ) {
- next->setTag( getTag()->clone() );
- }
- return next;
+ // TODO This is way too crude. It looks for string equality, but it should be looking for
+ // common parsed form
+ if (realOther->getQuery() != _query) {
+ return false;
+ }
+ if (realOther->getLanguage() != _language) {
+ return false;
+ }
+ if (realOther->getCaseSensitive() != _caseSensitive) {
+ return false;
}
+ return true;
+}
+LeafMatchExpression* TextMatchExpression::shallowClone() const {
+ TextMatchExpression* next = new TextMatchExpression();
+ next->init(_query, _language, _caseSensitive);
+ if (getTag()) {
+ next->setTag(getTag()->clone());
+ }
+ return next;
+}
}