ArangoDB v3.10 reached End of Life (EOL) and is no longer supported.
This documentation is outdated. Please see the most recent stable version.
Working with geo-spatial indexes
Create a geo-spatial index
Creates a geo-spatial index in the collection collection
, if
it does not already exist. Expects an object containing the index details.
Geo indexes are always sparse, meaning that documents that do not contain the index attributes or have non-numeric values in the index attributes will not be indexed.
fields* array of strings
An array with one or two attribute paths.
If it is an array with one attribute path
location
, then a geo-spatial index on all documents is created usinglocation
as path to the coordinates. The value of the attribute must be an array with at least two double values. The array must contain the latitude (first value) and the longitude (second value). All documents, which do not have the attribute path or with value that are not suitable, are ignored.If it is an array with two attribute paths
latitude
andlongitude
, then a geo-spatial index on all documents is created usinglatitude
andlongitude
as paths the latitude and the longitude. The values of thelatitude
andlongitude
attributes must each be a number (double). All documents which do not have the attribute paths or which have values that are not suitable are ignored.geoJson boolean
If a geo-spatial index on a
location
is constructed andgeoJson
istrue
, then the order within the array is longitude followed by latitude. This corresponds to the format described in http://geojson.org/geojson-spec.html#positionslegacyPolygons boolean
If
geoJson
is set totrue
, then this option controls how GeoJSON Polygons are interpreted.- If
legacyPolygons
istrue
, the smaller of the two regions defined by a linear ring is interpreted as the interior of the ring and a ring can at most enclose half the Earth’s surface. - If
legacyPolygons
isfalse
, the area to the left of the boundary ring’s path is considered to be the interior and a ring can enclose the entire surface of the Earth.
The default is
true
for geo indexes that were created in versions before 3.10, andfalse
for geo indexes created in 3.10 or later.- If
Examples
Creating a geo index with a location attribute
curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/index?collection=products
{
"type": "geo",
"fields": [
"b"
]
}
Creating a geo index with latitude and longitude attributes
curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/index?collection=products
{
"type": "geo",
"fields": [
"e",
"f"
]
}