diff options
Diffstat (limited to 'src/mongo/db/query/planner_ixselect.cpp')
| -rw-r--r-- | src/mongo/db/query/planner_ixselect.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mongo/db/query/planner_ixselect.cpp b/src/mongo/db/query/planner_ixselect.cpp index c2e06a1027a..b63484717f2 100644 --- a/src/mongo/db/query/planner_ixselect.cpp +++ b/src/mongo/db/query/planner_ixselect.cpp @@ -256,10 +256,9 @@ void QueryPlannerIXSelect::getFields(const MatchExpression* node, if (Indexability::nodeCanUseIndexOnOwnField(node)) { bool supportSparse = Indexability::nodeSupportedBySparseIndex(node); (*out)[prefix + node->path().toString()] = {supportSparse}; - } else if (Indexability::arrayUsesIndexOnChildren(node) && !node->path().empty()) { + } else if (Indexability::isBoundsGeneratingElemMatchObject(node)) { // If the array uses an index on its children, it's something like // {foo : {$elemMatch: {bar: 1}}}, in which case the predicate is really over foo.bar. - // Note we skip empty path components since they are not allowed in index key patterns. prefix += node->path().toString() + "."; for (size_t i = 0; i < node->numChildren(); ++i) { @@ -440,10 +439,13 @@ bool QueryPlannerIXSelect::_compatible(const BSONElement& keyPatternElt, const auto* child = node->getChild(0); const MatchExpression::MatchType childtype = child->matchType(); - // Can't index negations of MOD, REGEX, TYPE_OPERATOR, or ELEM_MATCH_VALUE. + // Can't index negations of MOD, REGEX, TYPE_OPERATOR, or ELEM_MATCH_VALUE; and, as + // above, we can't use a btree-indexed field for geo expressions (or their negations). if (MatchExpression::REGEX == childtype || MatchExpression::MOD == childtype || MatchExpression::TYPE_OPERATOR == childtype || - MatchExpression::ELEM_MATCH_VALUE == childtype) { + MatchExpression::ELEM_MATCH_VALUE == childtype || + MatchExpression::GEO == childtype || MatchExpression::GEO_NEAR == childtype || + MatchExpression::INTERNAL_BUCKET_GEO_WITHIN == childtype) { return false; } |
