[SERVER-31651] geoNear command and $geoNear agg stage should accept a "key" field Created: 19/Oct/17  Updated: 30/Oct/23  Resolved: 01/Dec/17

Status: Closed
Project: Core Server
Component/s: Aggregation Framework, Geo, Querying
Affects Version/s: None
Fix Version/s: 3.7.1

Type: Improvement Priority: Major - P3
Reporter: David Storch Assignee: David Storch
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
is documented by DOCS-11099 Docs for SERVER-31651: geoNear comman... Closed
Duplicate
is duplicated by SERVER-28976 Allow $geoNear on collections with mo... Closed
Backwards Compatibility: Fully Compatible
Sprint: Query 2017-11-13, Query 2017-12-04, Query 2017-12-18
Participants:

 Description   

The geoNear command and the $geoNear agg stage currently infer the field path over which to perform the search based on the presence of a "2d" or "2dsphere" index:

https://github.com/mongodb/mongo/blob/88c39edf9275e47e5db4b1dbffb0bf51f9187731/src/mongo/db/commands/geo_near_cmd.cpp#L124-L130

The command will fail if there are multiple geo indexes.

In order to improve this behavior, we should extend the command and agg stage to accept an optional key field. This field must be a string, and will be interpreted as the field path over which to run the search. In order to avoid breaking existing applications, the existing behavior should be preserved when the key field is omitted.



 Comments   
Comment by Githook User [ 01/Dec/17 ]

Author:

{'name': 'David Storch', 'username': 'dstorch', 'email': 'david.storch@10gen.com'}

Message: SERVER-31651 Extend geoNear command and agg stage to accept optional 'key' field.
Branch: master
https://github.com/mongodb/mongo/commit/7e06db21f8d55fa9a1d7b35a4de664f572d700c9

Comment by Githook User [ 01/Dec/17 ]

Author:

{'name': 'David Storch', 'username': 'dstorch', 'email': 'david.storch@10gen.com'}

Message: SERVER-31651 Relax geoNear command requirement to specify spherical=true for 2dsphere index.
Branch: master
https://github.com/mongodb/mongo/commit/173f1a09171c9a204a9757c355d3cc4efe0227dd

Comment by Githook User [ 01/Dec/17 ]

Author:

{'name': 'David Storch', 'username': 'dstorch', 'email': 'david.storch@10gen.com'}

Message: SERVER-31651 Allow minDistance option on geoNear command with 2d index.
Branch: master
https://github.com/mongodb/mongo/commit/71e6063873b8045a612c5f620bd910d99705bfcb

Comment by Andy Schwerin [ 21/Oct/17 ]

LGTM

Comment by Charlie Swanson [ 19/Oct/17 ]

"LGTM"

Comment by David Storch [ 19/Oct/17 ]

charlie.swanson schwerin ian.whalen, this is a pretty small improvement, so I don't think it warrants a formal review. Do you agree? If so, could you please just provide your "LGTM" here for the proposed syntax/behavior change?

Generated at Thu Feb 08 04:27:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.