-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix rewrite of near & nearSphere count queries using geoJson to geoWithin. #4006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
$near and $nearSphere queries are not supported via countDocuments and the used aggregation match stage and need to be rewritten to $geoWithin. The existing logic did not cover usage of geoJson types, which is fixed now. In case of nearSphere it is also required to convert the $maxDistance argument (given in meters for geoJson) to radians which is used by $geoWithin $centerSphere. Related to #2925
@@ -193,6 +196,24 @@ private static Document createGeoWithin(String key, Document source, @Nullable O | |||
return new Document("$and", criteria); | |||
} | |||
|
|||
private static Number getMaxDistance(Document source, Object $near, boolean spheric) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have MetricConversion
for some conversion calculations. It would make sense to reuse those bits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some, not all. Still we could move those bits there 👍
$near and $nearSphere queries are not supported via countDocuments and the used aggregation match stage and need to be rewritten to $geoWithin. The existing logic did not cover usage of geoJson types, which is fixed now. In case of nearSphere it is also required to convert the $maxDistance argument (given in meters for geoJson) to radians which is used by $geoWithin $centerSphere. Closes #4004 Original pull request: #4006. Related to #2925
$near and $nearSphere queries are not supported via countDocuments and the used aggregation match stage and need to be rewritten to $geoWithin. The existing logic did not cover usage of geoJson types, which is fixed now. In case of nearSphere it is also required to convert the $maxDistance argument (given in meters for geoJson) to radians which is used by $geoWithin $centerSphere. Closes #4004 Original pull request: #4006. Related to #2925
That's merged, polished, and backported now. |
$near
and$nearSphere
queries are not supported viacountDocuments
and the used aggregation match stage and need to be rewritten to$geoWithin
. The existing logic did not cover usage of geoJson types, which is fixed now. In case ofnearSphere
it is also required to convert the$maxDistance
argument (given in meters for geoJson) to radians which is used by$geoWithin $centerSphere
.Resolves: #4004