Skip to content

DOCS-1388 geospatial internals and 2d indexes #887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions source/applications/geospatial-indexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Geospatial Indexes and Queries

MongoDB offers a number of indexes and query mechanisms to handle
geospatial information. This section introduces MongoDB's geospatial
features.
features.

Surfaces
--------
Expand Down Expand Up @@ -109,11 +109,23 @@ geospatial queries:

- A compound index with only one additional field, as a suffix of the
``2d`` index field


Geospatial Indexes and Sharding
-------------------------------

You *cannot* use a geospatial index as the :term:`shard key` index.

You can create and maintain a geospatial index on
a sharded collection if using different fields as the shard key.

Queries using :operator:`$near` are not supported for sharded
collections. Use :dbcommand:`geoNear` instead. You also can query for
geospatial data using :operator:`$geoWithin`.

Additional Resources
--------------------

Consider the following pages for complete documentation of geospatial
The following pages provide complete documentation for geospatial
indexes and queries:

.. toctree::
Expand Down
37 changes: 13 additions & 24 deletions source/core/geospatial-indexes.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
==========================
Geospatial Index Internals
==========================
======================
``2d`` Index Internals
======================

.. default-domain:: mongodb

This document provides a more in-depth explanation of the internals of MongoDB's
geospatial features. This material is not necessary for normal operations
``2d`` geospatial indexes. This material is not necessary for normal operations
or application development but may be useful for troubleshooting and for
further understanding MongoDB's behavior and approach.

Geospatial Indexes and Sharding
-------------------------------

You *cannot* use a geospatial index as a :term:`shard key` when sharding
a collection. However, you can create and maintain a geospatial index on
a sharded collection by using a different field as the shard key. You
can query for geospatial data using :dbcommand:`geoNear` and
:operator:`$geoWithin`.

Queries using :operator:`$near` are not supported for sharded
collections. Use :dbcommand:`geoNear` instead.
further understanding.

.. _geospatial-indexes-geohash:

Geohash Values
--------------
Calculation of Geohash Values for ``2d`` Indexes
------------------------------------------------

When you create a geospatial index on legacy coordinate pairs, MongoDB computes
When you create a geospatial index on
:term:`legacy coordinate pairs <legacy coordinate pairs>`, MongoDB computes
:term:`geohash` values for the coordinate pairs within the specified
:ref:`range <geospatial-indexes-range>` and indexes the geohash values.
:ref:`location range <geospatial-indexes-range>` and then indexes the geohash values.

To calculate a geohash value, continuously divide a 2D map into
To calculate a geohash value, recursively divide a two-dimensional map into
quadrants. Then assign each quadrant a two-bit value. For example, a
two-bit representation of four quadrants would be:

Expand Down Expand Up @@ -62,8 +51,8 @@ geospatial index.

.. _geospatial-indexes-multi-location:

Multi-location Documents for 2D Indexes
---------------------------------------
Multi-location Documents for ``2d`` Indexes
-------------------------------------------

.. versionadded:: 2.0
Support for multiple locations in a document.
Expand Down
2 changes: 2 additions & 0 deletions source/reference/command/geoNear.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ geoNear

.. dbcommand:: geoNear

The :dbcommand:`geoNear` command specifies a point for which a
geospatial query returns the 100 closest documents.
The :dbcommand:`geoNear` command provides an alternative to the
:operator:`$near` operator. In addition to the functionality of
:operator:`$near`, :dbcommand:`geoNear` returns additional diagnostic
Expand Down
2 changes: 1 addition & 1 deletion source/reference/glossary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ Glossary
creation. MongoDB uses ObjectId values as the default values for
:term:`_id` fields.

Geohash
geohash
A value is a binary representation of the location on a
coordinate grid.

Expand Down