Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-3986

Add an example to 2d index creation

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 01112017-cleanup
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      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
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            william.cross William Cross
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              9 years, 35 weeks, 1 day ago