diff --git a/Documentation/Books/Manual/Indexing/Geo.mdpp b/Documentation/Books/Manual/Indexing/Geo.mdpp index e15f13ed08..99212e8fe1 100644 --- a/Documentation/Books/Manual/Indexing/Geo.mdpp +++ b/Documentation/Books/Manual/Indexing/Geo.mdpp @@ -94,20 +94,39 @@ Use GeoIndex with AQL SORT statement: @startDocuBlockInline geoIndexSortOptimization @EXAMPLE_ARANGOSH_OUTPUT{geoIndexSortOptimization} - ~db._create("geo3") - db.geo2.ensureIndex({ type: "geo", fields: [ "location.latitude", "location.longitude" ] }); + ~db._create("geoSort") + db.geoSort.ensureIndex({ type: "geo", fields: [ "latitude", "longitude" ] }); | for (i = -90; i <= 90; i += 10) { | for (j = -180; j <= 180; j += 10) { - | db.geo2.save({ name : "Name/" + i + "/" + j, location: { latitude : i, longitude : j } }); + | db.geoSort.save({ name : "Name/" + i + "/" + j, latitude : i, longitude : j }); | } } - var query = "FOR doc in geo3 SORT distance(doc.location.latitude, doc.location.longitude,0,0) LIMIT 100 RETURN doc" - db._explain(query); - db._execute(query); - ~db._drop("geo3") + var query = "FOR doc in geoSort SORT distance(doc.latitude, doc.longitude, 0, 0) LIMIT 5 RETURN doc" + db._explain(query, {}, {colors: false}); + db._query(query); + ~db._drop("geoSort") @END_EXAMPLE_ARANGOSH_OUTPUT @endDocuBlock geoIndexSortOptimization +Use GeoIndex with AQL FILTER statement: + + @startDocuBlockInline geoIndexFilterOptimization + @EXAMPLE_ARANGOSH_OUTPUT{geoIndexFilterOptimization} + ~db._create("geoFilter") + db.geoFilter.ensureIndex({ type: "geo", fields: [ "latitude", "longitude" ] }); + | for (i = -90; i <= 90; i += 10) { + | for (j = -180; j <= 180; j += 10) { + | db.geoFilter.save({ name : "Name/" + i + "/" + j, latitude : i, longitude : j }); + | } + } + var query = "FOR doc in geoFilter FILTER distance(doc.latitude, doc.longitude, 0, 0) < 2000 RETURN doc" + db._explain(query, {}, {colors: false}); + db._query(query); + ~db._drop("geoFilter") + @END_EXAMPLE_ARANGOSH_OUTPUT + @endDocuBlock geoIndexFilterOptimization + + @startDocuBlock collectionGeo diff --git a/Documentation/Books/Manual/Indexing/IndexBasics.mdpp b/Documentation/Books/Manual/Indexing/IndexBasics.mdpp index 7628809f0f..93c255ba2d 100644 --- a/Documentation/Books/Manual/Indexing/IndexBasics.mdpp +++ b/Documentation/Books/Manual/Indexing/IndexBasics.mdpp @@ -274,7 +274,7 @@ comparison coordinate, and to find documents with coordinates that are within a radius around a comparison coordinate. The geo index is used via dedicated functions in AQL, the simple queries -functions, and it is implicitly applied when in AQL a SORT or FILTER is used with +functions and it is implicitly applied when in AQL a SORT or FILTER is used with the distance function. Otherwise it will not be used for other types of queries or conditions.