summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher
diff options
context:
space:
mode:
authorMaddie Zechar <mez2113@columbia.edu>2023-03-03 22:59:04 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-03-04 02:24:35 +0000
commit1dddbcb90ec75240c29f04e00bd9486585bdb198 (patch)
treec859e5ce254069d2284a8ebc419e25200b50eadc /src/mongo/db/matcher
parent83a31ef7599f567a16a98ed355adffd511d3677b (diff)
downloadmongo-1dddbcb90ec75240c29f04e00bd9486585bdb198.tar.gz
SERVER-57932 Improve error message for $near in aggregation to suggest workarounds
Diffstat (limited to 'src/mongo/db/matcher')
-rw-r--r--src/mongo/db/matcher/expression_parser.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mongo/db/matcher/expression_parser.cpp b/src/mongo/db/matcher/expression_parser.cpp
index d902fd617a4..8d64cd19abd 100644
--- a/src/mongo/db/matcher/expression_parser.cpp
+++ b/src/mongo/db/matcher/expression_parser.cpp
@@ -1216,7 +1216,12 @@ StatusWithMatchExpression parseGeo(boost::optional<StringData> name,
if ((allowedFeatures & MatchExpressionParser::AllowedFeatures::kGeoNear) == 0u) {
return {Status(ErrorCodes::Error(5626500),
- "$geoNear, $near, and $nearSphere are not allowed in this context")};
+ "$geoNear, $near, and $nearSphere are not allowed in this context, "
+ "as these operators require sorting geospatial data. If you do not "
+ "need sort, consider using $geoWithin instead. Check out "
+ "https://dochub.mongodb.org/core/near-sort-operation and "
+ "https://dochub.mongodb.org/core/nearSphere-sort-operation"
+ "for more details.")};
}
auto nq = std::make_unique<GeoNearExpression>(name ? name->toString() : "");