Database Reference
In-Depth Information
{
"v" : 1,
"key" : {
"addr.zip" : 1
},
"ns" : "mine.first",
"name" : "addr.zip_1"
}
]
When the field being indexed contains an Array object rather than a scalar
object, MongoDB automatically creates a multikey index. Each element of
the array is added to the index individually, so an array containing four
elements would be added to the index four times. This even works with
arrays that contain objects. In the previous example, if the addr field
contained an Array of address objects, each of the address objects' zip
fields would be added to the index.
Geospatial Indexing
Aside from the basic scalar field indexes, MongoDB supports several
specialized types of index that make it popular for certain applications.
The first is the geospatial index, which operates either on coordinate pairs
or GeoJSON objects. Coordinate pairs are an older format specific to
MongoDB, represented either as an array of two elements or as an object
containing lng and lat fields. These two representations are equivalent:
{lng: 10, lat: 20}
[10,20]
GeoJSON objects are a newer open source format used to describe
geospatial features. To represent a coordinate pair using GeoJSON, the
format looks like this:
{type:"Point",coordinates:[10,20]}
In addition to Point types, MongoDB also supports Line and Polygon types
when indexing.
Search WWH ::




Custom Search