[SERVER-37043] Allow multi ringed shapes to be used for $geoWithin. Created: 07/Sep/18 Updated: 27/Dec/23 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Geo |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Christoph Strobl | Assignee: | Backlog - Query Integration |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | qi-geo | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Assigned Teams: |
Query Integration
|
||||
| Participants: | |||||
| Description |
|
Add a way to specify minDistance to $geoWithin allowing querying for being in a ring shape, analogous to what $near/$nearSphere allowed with $minDistance and $maxDistance options. The only current workaround if $geoNear aggregation stage cannot be used is this query:
Original description: With the deprecation of count in favor of countDocuments it is no longer possible to use the $near operator with the new API. Unfortunately the alternative $geoWithin $center only supports radius whereas $near allowed having a ring specified by $minDistance & $maxDistance. There's no workaround for this, $geoWithin seems to only supports single ringed structures, so this might be more a server issue than a driver one. |
| Comments |
| Comment by Ana Meza [ 29/Mar/22 ] | ||||||||||||||||||||||||||||||||||||||||
|
Agreed during triage to send to Backlog | ||||||||||||||||||||||||||||||||||||||||
| Comment by Asya Kamsky [ 23/Oct/18 ] | ||||||||||||||||||||||||||||||||||||||||
|
P.S. I think 4. is just driver work since I think $geoNear already has all the options to emulate $match with $near or $nearSphere.
| ||||||||||||||||||||||||||||||||||||||||
| Comment by Asya Kamsky [ 23/Oct/18 ] | ||||||||||||||||||||||||||||||||||||||||
|
cstrobl I understand the issue now. There are two ways to express $near to countDocuments but neither of them is a straight transformation of existing syntax. For reference, one is $geoNear agg stage, the other is compound $and query with two $geoWithin clauses, one finding all within maxDistance the other negating all within minDistance. On our side we need to consider a number of options (some of them are already "in effect"):
In all above cases user can be the enduser or the framework built on top of the driver. While there is definite value in additional options/flexibility for $geoNear aggregation stage, the issue remains that $near, $nearSphere and $geoNear are all strange "filters" because they contain both a "$match" and a "$sort" which means they can't really be rewritten to be just a $match stage in a non-lossy way (this particular case is special only because we know we are just counting, but that won't be knowable in the more general case). This ticket will continue to track the ability to specify minDistance option to $geoNear agg stage while we discuss other issues brought up in discussion here. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Christoph Strobl [ 23/Oct/18 ] | ||||||||||||||||||||||||||||||||||||||||
|
The java driver offers dedicated count methods taking a Bson filter query. This query is wrapped in $match to be run as aggregation.
Using a $geoWithin $center filter works but lacks minDistance.
| ||||||||||||||||||||||||||||||||||||||||
| Comment by Asya Kamsky [ 22/Oct/18 ] | ||||||||||||||||||||||||||||||||||||||||
|
cstrobl can you clarify the limitation here? $geoNear aggregation stage has supported minDistance as well as maxDistance since 3.2.
|