summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_tree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/matcher/expression_tree.cpp')
-rw-r--r--src/mongo/db/matcher/expression_tree.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mongo/db/matcher/expression_tree.cpp b/src/mongo/db/matcher/expression_tree.cpp
index c24749ea7b3..2229f602895 100644
--- a/src/mongo/db/matcher/expression_tree.cpp
+++ b/src/mongo/db/matcher/expression_tree.cpp
@@ -37,6 +37,7 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/matcher/expression_always_boolean.h"
#include "mongo/db/matcher/expression_path.h"
+#include "mongo/db/matcher/expression_text_base.h"
namespace mongo {
@@ -324,6 +325,14 @@ void NotMatchExpression::debugString(StringBuilder& debug, int level) const {
boost::optional<StringData> NotMatchExpression::getPathIfNotWithSinglePathMatchExpressionTree(
MatchExpression* exp) {
if (auto pathMatch = dynamic_cast<PathMatchExpression*>(exp)) {
+ if (dynamic_cast<TextMatchExpressionBase*>(exp)) {
+ // While TextMatchExpressionBase derives from PathMatchExpression, text match
+ // expressions cannot be serialized in the same manner as other PathMatchExpression
+ // derivatives. This is because the path for a TextMatchExpression is embedded within
+ // the $text object, whereas for other PathMatchExpressions it is on the left-hand-side,
+ // for example {x: {$eq: 1}}.
+ return boost::none;
+ }
return pathMatch->path();
}
@@ -331,7 +340,7 @@ boost::optional<StringData> NotMatchExpression::getPathIfNotWithSinglePathMatchE
boost::optional<StringData> path;
for (size_t i = 0; i < exp->numChildren(); ++i) {
auto pathMatchChild = dynamic_cast<PathMatchExpression*>(exp->getChild(i));
- if (!pathMatchChild) {
+ if (!pathMatchChild || dynamic_cast<TextMatchExpressionBase*>(exp->getChild(i))) {
return boost::none;
}