ArangoDB v3.4 reached End of Life (EOL) and is no longer supported.

This documentation is outdated. Please see the most recent version here: Latest Docs

HTTP Interface for Simple Queries

The Simple Queries API is deprecated from version 3.4.0 on. These endpoints should no longer be used. They are superseded by AQL queries.

Simple Queries

This is an introduction to ArangoDB’s HTTP interface for simple queries.

Simple queries can be used if the query condition is straight forward simple, i.e., a document reference, all documents, a query-by-example, or a simple geo query. In a simple query you can specify exactly one collection and one condition. The result can then be sorted and can be split into pages.

Working with Simples Queries using HTTP

To limit the amount of results to be transferred in one batch, simple queries support a batchSize parameter that can optionally be used to tell the server to limit the number of results to be transferred in one batch to a certain value. If the query has more results than were transferred in one go, more results are waiting on the server so they can be fetched subsequently. If no value for the batchSize parameter is specified, the server will use a reasonable default value.

If the server has more documents than should be returned in a single batch, the server will set the hasMore attribute in the result. It will also return the id of the server-side cursor in the id attribute in the result. This id can be used with the cursor API to fetch any outstanding results from the server and dispose the server-side cursor afterwards.

Return all documents

returns all documents of a collection

PUT /_api/simple/all

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Request Body

(string, required)

Contains the query.

Returns all documents of a collections. Equivalent to the AQL query FOR doc IN collection RETURN doc. The call expects a JSON object as body with the following attributes:

  • collection: The name of the collection to query.

  • skip: The number of documents to skip in the query (optional).

  • limit: The maximal amount of documents to return. The skip is applied before the limit restriction (optional).

  • batchSize: The number of documents to return in one go. (optional)

  • ttl: The time-to-live for the cursor (in seconds, optional).

  • stream: Create this cursor as a stream query (optional).

Returns a cursor containing the result, see HTTP Cursor for details.

Responses

HTTP 201: is returned if the query was executed successfully.

HTTP 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

HTTP 404: is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

Examples

Limit the amount of documents using limit

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/all <<EOF
{ "collection": "products", "skip": 2, "limit" : 2 }
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Using a batchSize value

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/all <<EOF
{ "collection": "products", "batchSize" : 3 }
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Simple query by-example

returns all documents of a collection matching a given example

PUT /_api/simple/by-example

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Till ArangoDB versions 3.2.13 and 3.3.7 this API is quite expensive. A more lightweight alternative is to use the HTTP Cursor API. Starting from versions 3.2.14 and 3.3.8 this performance impact is not an issue anymore, as the internal implementation of the API has changed.

Request Body

  • collection (string, required): The name of the collection to query.

  • example (string, required): The example document.

  • skip (string, required): The number of documents to skip in the query (optional).

  • limit (string, required): The maximal amount of documents to return. The skip is applied before the limit restriction. (optional)

  • batchSize (integer, optional): maximum number of result documents to be transferred from the server to the client in one roundtrip. If this attribute is not set, a server-controlled default value will be used. A batchSize value of 0 is disallowed.

This will find all documents matching a given example.

Returns a cursor containing the result, see HTTP Cursor for details.

Responses

HTTP 201: is returned if the query was executed successfully.

HTTP 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

HTTP 404: is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

Examples

Matching an attribute

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/by-example <<EOF
{ 
  "collection" : "products", 
  "example" : { 
    "i" : 1 
  } 
}
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Matching an attribute which is a sub-document

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/by-example <<EOF
{ 
  "collection" : "products", 
  "example" : { 
    "a.j" : 1 
  } 
}
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Matching an attribute within a sub-document

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/by-example <<EOF
{ 
  "collection" : "products", 
  "example" : { 
    "a" : { 
      "j" : 1 
    } 
  } 
}
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Find documents matching an example

returns one document of a collection matching a given example

PUT /_api/simple/first-example

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Till ArangoDB versions 3.2.13 and 3.3.7 this API is quite expensive. A more lightweight alternative is to use the HTTP Cursor API. Starting from versions 3.2.14 and 3.3.8 this performance impact is not an issue anymore, as the internal implementation of the API has changed.

Request Body

  • collection (string, required): The name of the collection to query.

  • example (string, required): The example document.

This will return the first document matching a given example.

Returns a result containing the document or HTTP 404 if no document matched the example.

If more than one document in the collection matches the specified example, only one of these documents will be returned, and it is undefined which of the matching documents is returned.

Responses

HTTP 200: is returned when the query was successfully executed.

HTTP 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

HTTP 404: is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

Examples

If a matching document was found

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/first-example <<EOF
{ 
  "collection" : "products", 
  "example" : { 
    "i" : 1 
  } 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

If no document was found

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/first-example <<EOF
{ 
  "collection" : "products", 
  "example" : { 
    "l" : 1 
  } 
}
EOF

HTTP/1.1 Not Found
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Find documents by their keys

fetches multiple documents by their keys

PUT /_api/simple/lookup-by-keys

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Request Body

  • collection (string, required): The name of the collection to look in for the documents

  • keys (array of strings, required): array with the _keys of documents to remove.

Looks up the documents in the specified collection using the array of keys provided. All documents for which a matching key was specified in the keys array and that exist in the collection will be returned. Keys for which no document can be found in the underlying collection are ignored, and no exception will be thrown for them.

Equivalent AQL query:

FOR doc IN @@collection FILTER doc._key IN @keys RETURN doc

The body of the response contains a JSON object with a documents attribute. The documents attribute is an array containing the matching documents. The order in which matching documents are present in the result array is unspecified.

Responses

HTTP 200: is returned if the operation was carried out successfully.

HTTP 404: is returned if the collection was not found. The response body contains an error document in this case.

HTTP 405: is returned if the operation was called with a different HTTP METHOD than PUT.

Examples

Looking up existing documents

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/lookup-by-keys <<EOF
{ 
  "keys" : [ 
    "test0", 
    "test1", 
    "test2", 
    "test3", 
    "test4", 
    "test5", 
    "test6", 
    "test7", 
    "test8", 
    "test9" 
  ], 
  "collection" : "test" 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Looking up non-existing documents

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/lookup-by-keys <<EOF
{ 
  "keys" : [ 
    "foo", 
    "bar", 
    "baz" 
  ], 
  "collection" : "test" 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Return a random document

returns a random document from a collection

PUT /_api/simple/any

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Request Body

  • collection (string, required): The identifier or name of the collection to query.

    Returns a JSON object with the document stored in the attribute document if the collection contains at least one document. If the collection is empty, the document attribute contains null.

Returns a random document from a collection. The call expects a JSON object as body with the following attributes:

Responses

HTTP 200: is returned if the query was executed successfully.

HTTP 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

HTTP 404: is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

Examples

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/any <<EOF
{ 
  "collection" : "products" 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Remove documents by their keys

removes multiple documents by their keys

PUT /_api/simple/remove-by-keys

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Request Body

  • collection (string, required): The name of the collection to look in for the documents to remove

  • keys (array of strings, required): array with the _keys of documents to remove.

  • options (object, optional): a json object which can contains following attributes:

    • waitForSync (boolean, optional): if set to true, then all removal operations will instantly be synchronized to disk. If this is not specified, then the collection’s default sync behavior will be applied.

    • silent (boolean, optional): if set to false, then the result will contain an additional attribute old which contains an array with one entry for each removed document. By default, these entries will have the _id, _key and _rev attributes.

    • returnOld (boolean, optional): if set to true and silent above is false, then the above information about the removed documents contains the complete removed documents.

Looks up the documents in the specified collection using the array of keys provided, and removes all documents from the collection whose keys are contained in the keys array. Keys for which no document can be found in the underlying collection are ignored, and no exception will be thrown for them.

Equivalent AQL query (the RETURN clause is optional):

FOR key IN @keys REMOVE key IN @@collection
  RETURN OLD

The body of the response contains a JSON object with information how many documents were removed (and how many were not). The removed attribute will contain the number of actually removed documents. The ignored attribute will contain the number of keys in the request for which no matching document could be found.

Responses

HTTP 200: is returned if the operation was carried out successfully. The number of removed documents may still be 0 in this case if none of the specified document keys were found in the collection.

HTTP 404: is returned if the collection was not found. The response body contains an error document in this case.

HTTP 405: is returned if the operation was called with a different HTTP METHOD than PUT.

Examples

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/remove-by-keys <<EOF
{ 
  "keys" : [ 
    "test0", 
    "test1", 
    "test2", 
    "test3", 
    "test4", 
    "test5", 
    "test6", 
    "test7", 
    "test8", 
    "test9" 
  ], 
  "collection" : "test" 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body
shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/remove-by-keys <<EOF
{ 
  "keys" : [ 
    "foo", 
    "bar", 
    "baz" 
  ], 
  "collection" : "test" 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Remove documents by example

removes all documents of a collection that match an example

PUT /_api/simple/remove-by-example

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Request Body

  • collection (string, required): The name of the collection to remove from.

  • example (string, required): An example document that all collection documents are compared against.

  • options (object, optional): a json object which can contains following attributes:

    • waitForSync (boolean, optional): if set to true, then all removal operations will instantly be synchronized to disk. If this is not specified, then the collection’s default sync behavior will be applied.

    • limit (string, required): an optional value that determines how many documents to delete at most. If limit is specified but is less than the number of documents in the collection, it is undefined which of the documents will be deleted.

This will find all documents in the collection that match the specified example object.

Note: the limit attribute is not supported on sharded collections. Using it will result in an error.

Returns the number of documents that were deleted.

Responses

HTTP 200: is returned if the query was executed successfully.

HTTP 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

HTTP 404: is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

Examples

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/remove-by-example <<EOF
{ 
  "collection" : "products", 
  "example" : { 
    "a" : { 
      "j" : 1 
    } 
  } 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Using Parameter: waitForSync and limit

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/remove-by-example <<EOF
{ 
  "collection" : "products", 
  "example" : { 
    "a" : { 
      "j" : 1 
    } 
  }, 
  "waitForSync" : true, 
  "limit" : 2 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Using Parameter: waitForSync and limit with new signature

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/remove-by-example <<EOF
{ 
  "collection" : "products", 
  "example" : { 
    "a" : { 
      "j" : 1 
    } 
  }, 
  "options" : { 
    "waitForSync" : true, 
    "limit" : 2 
  } 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Replace documents by example

replaces the body of all documents of a collection that match an example

PUT /_api/simple/replace-by-example

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Request Body

  • collection (string, required): The name of the collection to replace within.

  • example (string, required): An example document that all collection documents are compared against.

  • newValue (string, required): The replacement document that will get inserted in place of the “old” documents.

  • options (object, optional): a json object which can contain following attributes

    • waitForSync (boolean, optional): if set to true, then all removal operations will instantly be synchronized to disk. If this is not specified, then the collection’s default sync behavior will be applied.

    • limit (string, optional): an optional value that determines how many documents to replace at most. If limit is specified but is less than the number of documents in the collection, it is undefined which of the documents will be replaced.

This will find all documents in the collection that match the specified example object, and replace the entire document body with the new value specified. Note that document meta-attributes such as _id, _key, _from, _to etc. cannot be replaced.

Note: the limit attribute is not supported on sharded collections. Using it will result in an error.

Returns the number of documents that were replaced.

Responses

HTTP 200: is returned if the query was executed successfully.

HTTP 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

HTTP 404: is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

Examples

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/replace-by-example <<EOF
{ 
  "collection" : "products", 
  "example" : { 
    "a" : { 
      "j" : 1 
    } 
  }, 
  "newValue" : { 
    "foo" : "bar" 
  }, 
  "limit" : 3 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Using new Signature for attributes WaitForSync and limit

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/replace-by-example <<EOF
{ 
  "collection" : "products", 
  "example" : { 
    "a" : { 
      "j" : 1 
    } 
  }, 
  "newValue" : { 
    "foo" : "bar" 
  }, 
  "options" : { 
    "limit" : 3, 
    "waitForSync" : true 
  } 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Update documents by example

partially updates the body of all documents of a collection that match an example

PUT /_api/simple/update-by-example

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Request Body

  • collection (string, required): The name of the collection to update within.

  • example (string, required): An example document that all collection documents are compared against.

  • newValue (object, required): A document containing all the attributes to update in the found documents.

  • options (object, optional): a json object which can contains following attributes:

    • keepNull (boolean, optional): This parameter can be used to modify the behavior when handling null values. Normally, null values are stored in the database. By setting the keepNull parameter to false, this behavior can be changed so that all attributes in data with null values will be removed from the updated document.

    • waitForSync (boolean, optional): if set to true, then all removal operations will instantly be synchronized to disk. If this is not specified, then the collection’s default sync behavior will be applied.

    • limit (integer, optional): an optional value that determines how many documents to update at most. If limit is specified but is less than the number of documents in the collection, it is undefined which of the documents will be updated.

    • mergeObjects (boolean, optional): Controls whether objects (not arrays) will be merged if present in both the existing and the patch document. If set to false, the value in the patch document will overwrite the existing document’s value. If set to true, objects will be merged. The default is true.

This will find all documents in the collection that match the specified example object, and partially update the document body with the new value specified. Note that document meta-attributes such as _id, _key, _from, _to etc. cannot be replaced.

Note: the limit attribute is not supported on sharded collections. Using it will result in an error.

Returns the number of documents that were updated.

Responses

HTTP 200: is returned if the collection was updated successfully and waitForSync was true.

HTTP 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

HTTP 404: is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

Examples

using old syntax for options

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/update-by-example <<EOF
{ 
  "collection" : "products", 
  "example" : { 
    "a" : { 
      "j" : 1 
    } 
  }, 
  "newValue" : { 
    "a" : { 
      "j" : 22 
    } 
  }, 
  "limit" : 3 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

using new signature for options

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/update-by-example <<EOF
{ 
  "collection" : "products", 
  "example" : { 
    "a" : { 
      "j" : 1 
    } 
  }, 
  "newValue" : { 
    "a" : { 
      "j" : 22 
    } 
  }, 
  "options" : { 
    "limit" : 3, 
    "waitForSync" : true 
  } 
}
EOF

HTTP/1.1 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Simple range query

returns all documents of a collection within a range

PUT /_api/simple/range

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Request Body

  • collection (string, required): The name of the collection to query.

  • attribute (string, required): The attribute path to check.

  • left (string, required): The lower bound.

  • right (string, required): The upper bound.

  • closed (boolean, required): If true, use interval including left and right, otherwise exclude right, but include left.

  • skip (string, required): The number of documents to skip in the query (optional).

  • limit (integer, optional): The maximal amount of documents to return. The skip is applied before the limit restriction. (optional)

This will find all documents within a given range. In order to execute a range query, a skip-list index on the queried attribute must be present.

Returns a cursor containing the result, see HTTP Cursor for details.

Note: the range simple query is deprecated as of ArangoDB 2.6. The function may be removed in future versions of ArangoDB. The preferred way for retrieving documents from a collection within a specific range is to use an AQL query as follows:

FOR doc IN @@collection 
  FILTER doc.value >= @left && doc.value < @right 
  LIMIT @skip, @limit 
  RETURN doc`

Responses

HTTP 201: is returned if the query was executed successfully.

HTTP 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

HTTP 404: is returned if the collection specified by collection is unknown or no suitable index for the range query is present. The response body contains an error document in this case.

Examples

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/range <<EOF
{ 
  "collection" : "products", 
  "attribute" : "i", 
  "left" : 2, 
  "right" : 4 
}
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Returns documents near a coordinate

returns all documents of a collection near a given location

PUT /_api/simple/near

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Request Body

  • collection (string, required): The name of the collection to query.

  • latitude (string, required): The latitude of the coordinate.

  • longitude (string, required): The longitude of the coordinate.

  • distance (string, required): If given, the attribute key used to return the distance to the given coordinate. (optional). If specified, distances are returned in meters.

  • skip (string, required): The number of documents to skip in the query. (optional)

  • limit (string, required): The maximal amount of documents to return. The skip is applied before the limit restriction. The default is 100. (optional)

  • geo (string, required): If given, the identifier of the geo-index to use. (optional)

The default will find at most 100 documents near the given coordinate. The returned array is sorted according to the distance, with the nearest document being first in the return array. If there are near documents of equal distance, documents are chosen randomly from this set until the limit is reached.

In order to use the near operator, a geo index must be defined for the collection. This index also defines which attribute holds the coordinates for the document. If you have more than one geo-spatial index, you can use the geo field to select a particular index.

Returns a cursor containing the result, see HTTP Cursor for details.

Note: the near simple query is deprecated as of ArangoDB 2.6. This API may be removed in future versions of ArangoDB. The preferred way for retrieving documents from a collection using the near operator is to issue an AQL query using the NEAR function as follows:

FOR doc IN NEAR(@@collection, @latitude, @longitude, @limit)
  RETURN doc`

Responses

HTTP 201: is returned if the query was executed successfully.

HTTP 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

HTTP 404: is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

Examples

Without distance

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/near <<EOF
{ 
  "collection" : "products", 
  "latitude" : 0, 
  "longitude" : 0, 
  "skip" : 1, 
  "limit" : 2 
}
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

With distance

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/near <<EOF
{ 
  "collection" : "products", 
  "latitude" : 0, 
  "longitude" : 0, 
  "skip" : 1, 
  "limit" : 3, 
  "distance" : "distance" 
}
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Find documents within a radius around a coordinate

returns all documents of a collection within a given radius

PUT /_api/simple/within

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Request Body

  • collection (string, required): The name of the collection to query.

  • latitude (string, required): The latitude of the coordinate.

  • longitude (string, required): The longitude of the coordinate.

  • radius (string, required): The maximal radius (in meters).

  • distance (string, required): If given, the attribute key used to return the distance to the given coordinate. (optional). If specified, distances are returned in meters.

  • skip (string, required): The number of documents to skip in the query. (optional)

  • limit (string, required): The maximal amount of documents to return. The skip is applied before the limit restriction. The default is 100. (optional)

  • geo (string, required): If given, the identifier of the geo-index to use. (optional)

This will find all documents within a given radius around the coordinate (latitude, longitude). The returned list is sorted by distance.

In order to use the within operator, a geo index must be defined for the collection. This index also defines which attribute holds the coordinates for the document. If you have more than one geo-spatial index, you can use the geo field to select a particular index.

Returns a cursor containing the result, see HTTP Cursor for details.

Note: the within simple query is deprecated as of ArangoDB 2.6. This API may be removed in future versions of ArangoDB. The preferred way for retrieving documents from a collection using the near operator is to issue an AQL query using the WITHIN function as follows:

FOR doc IN WITHIN(@@collection, @latitude, @longitude, @radius, @distanceAttributeName)
  RETURN doc

Responses

HTTP 201: is returned if the query was executed successfully.

HTTP 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

HTTP 404: is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

Examples

Without distance

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/near <<EOF
{ 
  "collection" : "products", 
  "latitude" : 0, 
  "longitude" : 0, 
  "skip" : 1, 
  "limit" : 2, 
  "radius" : 500 
}
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

With distance

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/near <<EOF
{ 
  "collection" : "products", 
  "latitude" : 0, 
  "longitude" : 0, 
  "skip" : 1, 
  "limit" : 3, 
  "distance" : "distance", 
  "radius" : 300 
}
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Within rectangle query

returns all documents of a collection within a rectangle

PUT /_api/simple/within-rectangle

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Request Body

  • collection (string, required): The name of the collection to query.

  • latitude1 (string, required): The latitude of the first rectangle coordinate.

  • longitude1 (string, required): The longitude of the first rectangle coordinate.

  • latitude2 (string, required): The latitude of the second rectangle coordinate.

  • longitude2 (string, required): The longitude of the second rectangle coordinate.

  • skip (string, required): The number of documents to skip in the query. (optional)

  • limit (string, required): The maximal amount of documents to return. The skip is applied before the limit restriction. The default is 100. (optional)

  • geo (string, required): If given, the identifier of the geo-index to use. (optional)

This will find all documents within the specified rectangle (determined by the given coordinates (latitude1, longitude1, latitude2, longitude2).

In order to use the within-rectangle query, a geo index must be defined for the collection. This index also defines which attribute holds the coordinates for the document. If you have more than one geo-spatial index, you can use the geo field to select a particular index.

Returns a cursor containing the result, see HTTP Cursor for details.

Responses

HTTP 201: is returned if the query was executed successfully.

HTTP 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

HTTP 404: is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

Examples

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/within-rectangle <<EOF
{ 
  "collection" : "products", 
  "latitude1" : 0, 
  "longitude1" : 0, 
  "latitude2" : 0.2, 
  "longitude2" : 0.2, 
  "skip" : 1, 
  "limit" : 2 
}
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Fulltext index query

returns documents of a collection as a result of a fulltext query

PUT /_api/simple/fulltext

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

Request Body

  • collection (string, required): The name of the collection to query.

  • attribute (string, required): The attribute that contains the texts.

  • query (string, required): The fulltext query. Please refer to Fulltext queries for details.

  • skip (string, required): The number of documents to skip in the query (optional).

  • limit (string, required): The maximal amount of documents to return. The skip is applied before the limit restriction. (optional)

  • index (string, required): The identifier of the fulltext-index to use.

This will find all documents from the collection that match the fulltext query specified in query.

In order to use the fulltext operator, a fulltext index must be defined for the collection and the specified attribute.

Returns a cursor containing the result, see HTTP Cursor for details.

Note: the fulltext simple query is deprecated as of ArangoDB 2.6. This API may be removed in future versions of ArangoDB. The preferred way for retrieving documents from a collection using the near operator is to issue an AQL query using the FULLTEXT AQL function as follows:

FOR doc IN FULLTEXT(@@collection, @attributeName, @queryString, @limit) 
  RETURN doc

Responses

HTTP 201: is returned if the query was executed successfully.

HTTP 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

HTTP 404: is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

Examples

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/fulltext <<EOF
{ 
  "collection" : "products", 
  "attribute" : "text", 
  "query" : "word" 
}
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body