[DOCS-1642] geo operator cheat sheet has wrong syntax for $geoWithin with $center Created: 25/Jun/13  Updated: 30/Oct/23  Resolved: 25/Jun/13

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Bug Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: Sam Kleinman (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 10 years, 34 weeks, 1 day ago

 Description   

http://docs.mongodb.org/manual/reference/operator/query-geospatial/#geospatial-query-compatibility

This page says to use:

{ $geoWithin : {
  $center : [x1, y1],
  $maxDistance : d
} }

But this is invalid syntax:

> db.generated.find({ "location.coordinates": { $geoWithin: {$center: [40, 7.25], $maxDistance: .01}}})
error: {
	"$err" : "the first field of $center object must be a location object",
	"code" : 13656
}

This does work:

> db.generated.find({ "location.coordinates": { $geoWithin: {$center: [[40, 7.25], .01]}}})



 Comments   
Comment by auto [ 25/Jun/13 ]

Author:

{u'username': u'tychoish', u'name': u'Sam Kleinman', u'email': u'samk@10gen.com'}

Message: DOCS-1642: fixing syntax of geoWithin center queries
Branch: master
https://github.com/mongodb/docs/commit/e29166781958d043fe262e30f4d1096ba2b564ee

Generated at Thu Feb 08 07:41:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.