Create a 2dsphere Index MongoDB Documentation, Release 3.0.4 To create a geospatial index for GeoJSON-formatted data, use the db.collection.createIndex() method to create a 2dsphere index (page 496). In the index specification document for the db.collection.createIndex() method, specify the location field as the index key and specify the string literal "2dsphere" as the value: The following procedure presents steps to populate a collection with documents that contain a GeoJSON data field and create 2dsphere indexes (page 496). Although the procedure populates the collection first, you can also create the indexes before populating the collection. First, populate a collection places with documents that store location data as GeoJSON Point (page 553) in a field named loc . The coordinate order is longitude, then latitude. Procedure db.places.insert( { loc : { type: "Point", coordinates: [ -73.97, 40.77 ] }, name: "Central Park", category : "Parks" } ) db.places.insert( { loc : { type: "Point", coordinates: [ -73.88, 40.78 ] }, name: "La Guardia Airport", category : "Airport" } ) Then, create the 2dsphere (page 496) index. Create a 2dsphere Index For example, the following creates a 2dsphere (page 496) index on the location field loc : Create a Compound Index with 2dsphere Index Key A compound index (page 489) can include a 2dsphere index key in combination with non-geospatial index keys. For example, the following operation creates a compound index where the first key loc is a 2dsphere index key, and the remaining keys category and names are non- geospatial index keys, specifically descending ( -1 ) and ascending ( 1 ) keys respectively. Unlike the 2d (page 497) index, a compound 2dsphere index does not require the location field to be the first field indexed. For example: Chapter 8. Indexes 530 db.collection.createIndex( { <location field> : "2dsphere" } ) db.places.createIndex( { loc : "2dsphere" } ) db.places.createIndex( { category : 1 , loc : "2dsphere" } ) db.places.createIndex( { loc : "2dsphere" , category : -1, name: 1 } )