MongoDB geospatial Index
1. Index:
Creating an index takes both time and effort, and consumes a lot of resources. You can use the {"bakckground": true} Option to complete the process in the background and process the request properly. If the background is not included
This option blocks all requests during index creation. Blocking will make the index build faster, and it also means that the application cannot respond during this period. Even running on the background may affect normal operations.
2. geospatial index:
In general, it is to find the N locations closest to the current location. By default, the range of the expected geospatial index value is-180 ~ 180. To use other values, you can use the ensureIndex option to specify the maximum and minimum values:
> Db. star. trek. ensureIndex ({"light-years": "2d" },{ "min":-1000, "max": 1000 });
In this way, a spatial index of 2000 light years is created.
The following is an example of "$ near:
> Db. map. find ({"gps": {"$ near": [40,-73]}). limit (10)
You can also use geoNear.
> Db. runCommand ({geoNear: "map", near: [40,-70], num: 10 });
GeoNear returns the distance from each document to the query point. This distance is measured in units of the data you inserted. If you insert the distance from the latitude and longitude angle, the distance is the latitude and longitude.
You can also specify documents in the shape.
For example, $ center is used to locate all sites in the circle.
> Db. map. find ({"gps": {"within": {"center": [], 5] }});
3. mongo's Geospatial index assumes that the index content is on a plane. This means that the sphere, such as the Earth, is not very precise, especially in polar regions. Specifically, the length of the weft line between the two warp wires is different between the equator and in the child blank area, and the latter is much shorter.
MongoDB 3.0 official version released and downloaded
CentOS compilation and installation of MongoDB
CentOS compilation and installation of php extensions for MongoDB and mongoDB
CentOS 6 install MongoDB and server configuration using yum
Install MongoDB2.4.3 in Ubuntu 13.04
MongoDB beginners must read (both concepts and practices)
MongoDB Installation Guide for Ubunu 14.04
MongoDB authoritative Guide (The Definitive Guide) in English [PDF]
Nagios monitoring MongoDB sharded cluster service practice
Build MongoDB Service Based on CentOS 6.5 Operating System
MongoDB details: click here
MongoDB: click here
This article permanently updates the link address: