[DOCS-3986] Add an example to 2d index creation Created: 03/Sep/14  Updated: 11/Jan/17  Resolved: 03/Sep/14

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: 01112017-cleanup

Type: Task Priority: Major - P3
Reporter: William Cross Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 9 years, 24 weeks ago

 Description   

The docs recommend a functionality I'm having trouble implementing.

Reference page: http://docs.mongodb.org/manual/tutorial/build-a-2d-index/

Also relevant: http://docs.mongodb.org/manual/core/2d/, http://docs.mongodb.org/manual/core/geospatial-indexes/

I see that the format is

db.<collection>.ensureIndex( { <location field> : "2d" ,
                               <additional field> : <value> } ,
                             { <index-specification options> } )

and index options are

{ min : <lower bound> , max : <upper bound> ,
  bits : <bit precision> }

Steps to try to reproduce this:

> db.2dindex.ensureIndex( { coords : "2d", name : 1 }, { min : -180, max : 180, bits : 10 } )
2014-09-03T10:37:24.819-0400 SyntaxError: Unexpected token ILLEGAL
> db.2dindex.ensureIndex( { coords : "2d"}, { min : [ -180, -90 ], max : [ 180, 90 ], bits : 10 } )
2014-09-03T10:39:23.576-0400 SyntaxError: Unexpected token ILLEGAL
> db.2dindex.ensureIndex( { coords : "2d"}, { } )
2014-09-03T10:47:36.811-0400 SyntaxError: Unexpected token ILLEGAL
> db.2dindex.ensureIndex( { coords : "2d"}, { min : { lng : -180, lat : -90 }, max : { lng : 180, lat : 90 } } )
2014-09-03T10:50:09.806-0400 SyntaxError: Unexpected token ILLEGAL



 Comments   
Comment by Kay Kim (Inactive) [ 03/Sep/14 ]

discussed in person

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