summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/parsed_projection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/parsed_projection.cpp')
-rw-r--r--src/mongo/db/query/parsed_projection.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mongo/db/query/parsed_projection.cpp b/src/mongo/db/query/parsed_projection.cpp
index ef2bf600e5a..a61b5821b2d 100644
--- a/src/mongo/db/query/parsed_projection.cpp
+++ b/src/mongo/db/query/parsed_projection.cpp
@@ -52,6 +52,8 @@ namespace mongo {
bool includeID = true;
+ bool hasIndexKeyProjection = false;
+
// Until we see a positional or elemMatch operator we're normal.
ArrayOpType arrayOpType = ARRAY_OP_NORMAL;
@@ -136,10 +138,15 @@ namespace mongo {
}
if (!mongoutils::str::equals(e2.valuestr(), "text")
- && !mongoutils::str::equals(e2.valuestr(), "diskloc")) {
+ && !mongoutils::str::equals(e2.valuestr(), "diskloc")
+ && !mongoutils::str::equals(e2.valuestr(), "indexKey")) {
return Status(ErrorCodes::BadValue,
"unsupported $meta operator: " + e2.str());
}
+
+ if (mongoutils::str::equals(e2.valuestr(), "indexKey")) {
+ hasIndexKeyProjection = true;
+ }
}
else {
return Status(ErrorCodes::BadValue,
@@ -197,6 +204,13 @@ namespace mongo {
verify(spec.isOwned());
pp->_source = spec;
+ // returnKey clobbers everything.
+ if (hasIndexKeyProjection) {
+ pp->_requiresDocument = false;
+ *out = pp.release();
+ return Status::OK();
+ }
+
// Dotted fields aren't covered, non-simple require match details, and as for include, "if
// we default to including then we can't use an index because we don't know what we're
// missing."