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
{
"result" : [
{
"_key" : "69945",
"_id" : "products/69945",
"_rev" : "_bHcRMUq--A",
"Hello3" : "World3"
},
{
"_key" : "69947",
"_id" : "products/69947",
"_rev" : "_bHcRMUu---",
"Hello4" : "World4"
}
],
"hasMore" : false,
"count" : 2,
"cached" : false,
"extra" : {
"stats" : {
"writesExecuted" : 0,
"writesIgnored" : 0,
"scannedFull" : 4,
"scannedIndex" : 0,
"filtered" : 0,
"httpRequests" : 0,
"executionTime" : 0.000270843505859375,
"peakMemoryUsage" : 2510
},
"warnings" : [ ]
},
"error" : false,
"code" : 201
}
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
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
{
"result" : [
{
"_key" : "69922",
"_id" : "products/69922",
"_rev" : "_bHcRMTq---",
"Hello1" : "World1"
},
{
"_key" : "69924",
"_id" : "products/69924",
"_rev" : "_bHcRMTq--A",
"Hello2" : "World2"
},
{
"_key" : "69926",
"_id" : "products/69926",
"_rev" : "_bHcRMTu---",
"Hello3" : "World3"
}
],
"hasMore" : true,
"id" : "69932",
"count" : 5,
"extra" : {
"stats" : {
"writesExecuted" : 0,
"writesIgnored" : 0,
"scannedFull" : 5,
"scannedIndex" : 0,
"filtered" : 0,
"httpRequests" : 0,
"executionTime" : 0.00044989585876464844,
"peakMemoryUsage" : 18351
},
"warnings" : [ ]
},
"cached" : false,
"error" : false,
"code" : 201
}
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
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
{
"result" : [
{
"_key" : "69977",
"_id" : "products/69977",
"_rev" : "_bHcRMWW---",
"a" : {
"k" : 1,
"j" : 1
},
"i" : 1
},
{
"_key" : "69979",
"_id" : "products/69979",
"_rev" : "_bHcRMWa---",
"a" : {
"j" : 1
},
"i" : 1
},
{
"_key" : "69981",
"_id" : "products/69981",
"_rev" : "_bHcRMWa--A",
"i" : 1
},
{
"_key" : "69983",
"_id" : "products/69983",
"_rev" : "_bHcRMWe---",
"a" : {
"k" : 2,
"j" : 2
},
"i" : 1
}
],
"hasMore" : false,
"count" : 4,
"cached" : false,
"extra" : {
"stats" : {
"writesExecuted" : 0,
"writesIgnored" : 0,
"scannedFull" : 4,
"scannedIndex" : 0,
"filtered" : 0,
"httpRequests" : 0,
"executionTime" : 0.00043129920959472656,
"peakMemoryUsage" : 36641
},
"warnings" : [ ]
},
"error" : false,
"code" : 201
}
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
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
{
"result" : [
{
"_key" : "69993",
"_id" : "products/69993",
"_rev" : "_bHcRMXK---",
"a" : {
"k" : 1,
"j" : 1
},
"i" : 1
},
{
"_key" : "69995",
"_id" : "products/69995",
"_rev" : "_bHcRMXO---",
"a" : {
"j" : 1
},
"i" : 1
}
],
"hasMore" : false,
"count" : 2,
"cached" : false,
"extra" : {
"stats" : {
"writesExecuted" : 0,
"writesIgnored" : 0,
"scannedFull" : 4,
"scannedIndex" : 0,
"filtered" : 2,
"httpRequests" : 0,
"executionTime" : 0.00035691261291503906,
"peakMemoryUsage" : 36921
},
"warnings" : [ ]
},
"error" : false,
"code" : 201
}
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
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
{
"result" : [
{
"_key" : "70011",
"_id" : "products/70011",
"_rev" : "_bHcRMY---A",
"a" : {
"j" : 1
},
"i" : 1
}
],
"hasMore" : false,
"count" : 1,
"cached" : false,
"extra" : {
"stats" : {
"writesExecuted" : 0,
"writesIgnored" : 0,
"scannedFull" : 4,
"scannedIndex" : 0,
"filtered" : 3,
"httpRequests" : 0,
"executionTime" : 0.00042057037353515625,
"peakMemoryUsage" : 37201
},
"warnings" : [ ]
},
"error" : false,
"code" : 201
}
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
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
{
"document" : {
"_key" : "70025",
"_id" : "products/70025",
"_rev" : "_bHcRMYy---",
"a" : {
"k" : 1,
"j" : 1
},
"i" : 1
},
"error" : false,
"code" : 200
}
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
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
{
"error" : true,
"code" : 404,
"errorNum" : 404,
"errorMessage" : "no match"
}
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
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
{
"documents" : [
{
"_key" : "test0",
"_id" : "test/test0",
"_rev" : "_bHcRMb6---",
"value" : 0
},
{
"_key" : "test1",
"_id" : "test/test1",
"_rev" : "_bHcRMc----",
"value" : 1
},
{
"_key" : "test2",
"_id" : "test/test2",
"_rev" : "_bHcRMcC---",
"value" : 2
},
{
"_key" : "test3",
"_id" : "test/test3",
"_rev" : "_bHcRMcC--A",
"value" : 3
},
{
"_key" : "test4",
"_id" : "test/test4",
"_rev" : "_bHcRMcG---",
"value" : 4
},
{
"_key" : "test5",
"_id" : "test/test5",
"_rev" : "_bHcRMcK---",
"value" : 5
},
{
"_key" : "test6",
"_id" : "test/test6",
"_rev" : "_bHcRMcK--A",
"value" : 6
},
{
"_key" : "test7",
"_id" : "test/test7",
"_rev" : "_bHcRMcO---",
"value" : 7
},
{
"_key" : "test8",
"_id" : "test/test8",
"_rev" : "_bHcRMcS---",
"value" : 8
},
{
"_key" : "test9",
"_id" : "test/test9",
"_rev" : "_bHcRMcS--A",
"value" : 9
}
],
"error" : false,
"code" : 200
}
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
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
{
"documents" : [ ],
"error" : false,
"code" : 200
}
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
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
{
"document" : {
"_key" : "69965",
"_id" : "products/69965",
"_rev" : "_bHcRMVi---",
"Hello4" : "World4"
},
"error" : false,
"code" : 200
}
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
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
{
"removed" : 10,
"ignored" : 0,
"error" : false,
"code" : 200
}
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
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
{
"removed" : 0,
"ignored" : 3,
"error" : false,
"code" : 200
}
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
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
{
"deleted" : 1,
"error" : false,
"code" : 200
}
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
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
{
"deleted" : 1,
"error" : false,
"code" : 200
}
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
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
{
"deleted" : 1,
"error" : false,
"code" : 200
}
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
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
{
"replaced" : 1,
"error" : false,
"code" : 200
}
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
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
{
"replaced" : 1,
"error" : false,
"code" : 200
}
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
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
{
"updated" : 1,
"error" : false,
"code" : 200
}
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
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
{
"updated" : 1,
"error" : false,
"code" : 200
}
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
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
{
"result" : [
{
"_key" : "70187",
"_id" : "products/70187",
"_rev" : "_bHcRMhS---",
"i" : 2
},
{
"_key" : "70189",
"_id" : "products/70189",
"_rev" : "_bHcRMhS--A",
"i" : 3
}
],
"hasMore" : false,
"count" : 2,
"error" : false,
"code" : 201
}
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
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
{
"result" : [
{
"_key" : "70123",
"_id" : "products/70123",
"_rev" : "_bHcRMea--A",
"name" : "Name/-0.002/",
"loc" : [
-0.002,
0
]
},
{
"_key" : "70127",
"_id" : "products/70127",
"_rev" : "_bHcRMee--A",
"name" : "Name/0.002/",
"loc" : [
0.002,
0
]
}
],
"hasMore" : false,
"count" : 2,
"error" : false,
"code" : 201
}
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
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
{
"result" : [
{
"_id" : "products/70158",
"_key" : "70158",
"_rev" : "_bHcRMf2---",
"loc" : [
-0.002,
0
],
"name" : "Name/-0.002/",
"distance" : 222.3898532891175
},
{
"_id" : "products/70162",
"_key" : "70162",
"_rev" : "_bHcRMf6---",
"loc" : [
0.002,
0
],
"name" : "Name/0.002/",
"distance" : 222.3898532891175
},
{
"_id" : "products/70164",
"_key" : "70164",
"_rev" : "_bHcRMg----",
"loc" : [
0.004,
0
],
"name" : "Name/0.004/",
"distance" : 444.779706578235
}
],
"hasMore" : false,
"count" : 3,
"error" : false,
"code" : 201
}
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
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
{
"result" : [
{
"_key" : "70361",
"_id" : "products/70361",
"_rev" : "_bHcRMre--A",
"name" : "Name/-0.002/",
"loc" : [
-0.002,
0
]
},
{
"_key" : "70365",
"_id" : "products/70365",
"_rev" : "_bHcRMri--A",
"name" : "Name/0.002/",
"loc" : [
0.002,
0
]
}
],
"hasMore" : false,
"count" : 2,
"error" : false,
"code" : 201
}
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
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
{
"result" : [
{
"_id" : "products/70396",
"_key" : "70396",
"_rev" : "_bHcRMs2---",
"loc" : [
-0.002,
0
],
"name" : "Name/-0.002/",
"distance" : 222.3898532891175
},
{
"_id" : "products/70400",
"_key" : "70400",
"_rev" : "_bHcRMs6--A",
"loc" : [
0.002,
0
],
"name" : "Name/0.002/",
"distance" : 222.3898532891175
},
{
"_id" : "products/70402",
"_key" : "70402",
"_rev" : "_bHcRMt----",
"loc" : [
0.004,
0
],
"name" : "Name/0.004/",
"distance" : 444.779706578235
}
],
"hasMore" : false,
"count" : 3,
"error" : false,
"code" : 201
}
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
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
{
"result" : [
{
"_key" : "70441",
"_id" : "products/70441",
"_rev" : "_bHcRMui---",
"name" : "Name/0.008/",
"loc" : [
0.008,
0
]
},
{
"_key" : "70439",
"_id" : "products/70439",
"_rev" : "_bHcRMue--A",
"name" : "Name/0.006/",
"loc" : [
0.006,
0
]
}
],
"hasMore" : false,
"count" : 2,
"error" : false,
"code" : 201
}
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
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
{
"result" : [
{
"_key" : "70057",
"_id" : "products/70057",
"_rev" : "_bHcRMaq---",
"text" : "this text contains word"
},
{
"_key" : "70059",
"_id" : "products/70059",
"_rev" : "_bHcRMau---",
"text" : "this text also has a word"
}
],
"hasMore" : false,
"count" : 2,
"error" : false,
"code" : 201
}
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