MongoDB geospatial Index

Source: Internet
Author: User
Tags install mongodb

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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.