Accessing Cursors via HTTP
Create cursor
create a cursor and return the first results
POST /_api/cursor
Header Parameters
-
x-arango-allow-dirty-read (boolean, optional): Set this header to
true
to allow the Coordinator to ask any shard replica for the data, not only the shard leader. This may result in “dirty reads”.The header is ignored if this operation is part of a Stream Transaction (
x-arango-trx-id
header). The header set when creating the transaction decides about dirty reads for the entire transaction, not the individual read operations. -
x-arango-trx-id (string, optional): To make this operation a part of a Stream Transaction, set this header to the transaction ID returned by the
POST /_api/transaction/begin
call.
Request Body
-
query (string, required): contains the query string to be executed
-
count (boolean, optional): indicates whether the number of documents in the result set should be returned in the “count” attribute of the result. Calculating the “count” attribute might have a performance impact for some queries in the future so this option is turned off by default, and “count” is only returned when requested.
-
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.
-
ttl (integer, optional): The time-to-live for the cursor (in seconds). If the result set is small enough (less than or equal to
batchSize
) then results are returned right away. Otherwise they are stored in memory and will be accessible via the cursor with respect to thettl
. The cursor will be removed on the server automatically after the specified amount of time. This is useful to ensure garbage collection of cursors that are not fully fetched by clients. If not set, a server-defined value will be used (default: 30 seconds). -
cache (boolean, optional): flag to determine whether the AQL query results cache shall be used. If set to false, then any query cache lookup will be skipped for the query. If set to true, it will lead to the query cache being checked for the query if the query cache mode is either on or demand.
-
memoryLimit (integer, optional): the maximum number of memory (measured in bytes) that the query is allowed to use. If set, then the query will fail with error “resource limit exceeded” in case it allocates too much memory. A value of 0 indicates that there is no memory limit.
-
bindVars (array of objects, optional): key/value pairs representing the bind parameters.
-
options (object, optional): key/value object with extra options for the query.
-
fullCount (boolean, optional): if set to true and the query contains a LIMIT clause, then the result will have an extra attribute with the sub-attributes stats and fullCount,
{ ... , "extra": { "stats": { "fullCount": 123 } } }
. The fullCount attribute will contain the number of documents in the result before the last top-level LIMIT in the query was applied. It can be used to count the number of documents that match certain filter criteria, but only return a subset of them, in one go. It is thus similar to MySQL’s SQL_CALC_FOUND_ROWS hint. Note that setting the option will disable a few LIMIT optimizations and may lead to more documents being processed, and thus make queries run longer. Note that the fullCount attribute may only be present in the result if the query has a top-level LIMIT clause and the LIMIT clause is actually used in the query. -
fillBlockCache (boolean, optional): if set to true or not specified, this will make the query store the data it reads via the RocksDB storage engine in the RocksDB block cache. This is usually the desired behavior. The option can be set to false for queries that are known to either read a lot of data which would thrash the block cache, or for queries that read data which are known to be outside of the hot set. By setting the option to false, data read by the query will not make it into the RocksDB block cache if not already in there, thus leaving more room for the actual hot set.
-
maxNumberOfPlans (integer, optional): Limits the maximum number of plans that are created by the AQL query optimizer.
-
maxNodesPerCallstack (integer, optional): The number of execution nodes in the query plan after that stack splitting is performed to avoid a potential stack overflow. Defaults to the configured value of the startup option
--query.max-nodes-per-callstack
.This option is only useful for testing and debugging and normally does not need any adjustment.
-
maxWarningCount (integer, optional): Limits the maximum number of warnings a query will return. The number of warnings a query will return is limited to 10 by default, but that number can be increased or decreased by setting this attribute.
-
failOnWarning (boolean, optional): When set to true, the query will throw an exception and abort instead of producing a warning. This option should be used during development to catch potential issues early. When the attribute is set to false, warnings will not be propagated to exceptions and will be returned with the query result. There is also a server configuration option
--query.fail-on-warning
for setting the default value for failOnWarning so it does not need to be set on a per-query level. -
stream (boolean, optional): Can be enabled to execute the query lazily. If set to true, then the query is executed as long as necessary to produce up to
batchSize
results. These results are returned immediately and the query is suspended until the client asks for the next batch (if there are more results). Depending on the query this can mean that the first results will be available much faster and that less memory is needed because the server only needs to store a subset of results at a time. Read-only queries can benefit the most, unlessSORT
without index orCOLLECT
are involved that make it necessary to process all documents before a partial result can be returned. It is advisable to only use this option for queries without exclusive locks.Remarks:
- The query will hold resources until it ends (such as RocksDB snapshots, which prevents compaction to some degree). Writes will be in memory until the query is committed.
- If existing documents are modified, then write locks are held on these documents and other queries trying to modify the same documents will fail because of this conflict.
- A streaming query may fail late because of a conflict or for other reasons after some batches were already returned successfully, possibly rendering the results up to that point meaningless.
- The query options
cache
,count
andfullCount
are not supported for streaming queries. - Query statistics, profiling data and warnings are delivered as part of the last batch.
If the
stream
option is false (default), then the complete result of the query is calculated before any of it is returned to the client. The server stores the full result in memory (on the contacted Coordinator if in a cluster). All other resources are freed immediately (locks, RocksDB snapshots). The query will fail before it returns results in case of a conflict. -
spillOverThresholdMemoryUsage (integer, optional): This option allows queries to store intermediate and final results temporarily on disk if the amount of memory used (in bytes) exceeds the specified value. This is used for decreasing the memory usage during the query execution.
This option only has an effect on queries that use the
SORT
operation but without aLIMIT
, and if you enable the spillover feature by setting a path for the directory to store the temporary data in with the--temp.intermediate-results-path
startup option.Default value: 128MB.
Note: Spilling data from RAM onto disk is an experimental feature and is turned off by default. The query results are still built up entirely in RAM on Coordinators and single servers for non-streaming queries. To avoid the buildup of the entire query result in RAM, use a streaming query (see the
stream
option). -
spillOverThresholdNumRows (integer, optional): This option allows queries to store intermediate and final results temporarily on disk if the number of rows produced by the query exceeds the specified value. This is used for decreasing the memory usage during the query execution. In a query that iterates over a collection that contains documents, each row is a document, and in a query that iterates over temporary values (i.e.
FOR i IN 1..100
), each row is one of such temporary values.This option only has an effect on queries that use the
SORT
operation but without aLIMIT
, and if you enable the spillover feature by setting a path for the directory to store the temporary data in with the--temp.intermediate-results-path
startup option.Default value:
5000000
rows.Note: Spilling data from RAM onto disk is an experimental feature and is turned off by default. The query results are still built up entirely in RAM on Coordinators and single servers for non-streaming queries. To avoid the buildup of the entire query result in RAM, use a streaming query (see the
stream
option). -
optimizer (object, optional): Options related to the query optimizer.
- rules (array of strings, optional):
A list of to-be-included or to-be-excluded optimizer rules can be put into this
attribute, telling the optimizer to include or exclude specific rules. To disable
a rule, prefix its name with a
-
, to enable a rule, prefix it with a+
. There is also a pseudo-ruleall
, which matches all optimizer rules.-all
disables all rules.
- rules (array of strings, optional):
A list of to-be-included or to-be-excluded optimizer rules can be put into this
attribute, telling the optimizer to include or exclude specific rules. To disable
a rule, prefix its name with a
-
profile (integer, optional): If set to
true
or1
, then the additional query profiling information is returned in theprofile
sub-attribute of theextra
return attribute, unless the query result is served from the query cache. If set to2
, the query includes execution stats per query plan node instats.nodes
sub-attribute of theextra
return attribute. Additionally, the query plan is returned in theextra.plan
sub-attribute. -
satelliteSyncWait (number, optional): This Enterprise Edition parameter allows to configure how long a DB-Server has time to bring the SatelliteCollections involved in the query into sync. The default value is
60.0
seconds. When the maximal time is reached, the query is stopped. -
maxRuntime (number, optional): The query has to be executed within the given runtime or it is killed. The value is specified in seconds. The default value is
0.0
(no timeout). -
maxTransactionSize (integer, optional): The transaction size limit in bytes.
-
intermediateCommitSize (integer, optional): The maximum total size of operations after which an intermediate commit is performed automatically.
-
intermediateCommitCount (integer, optional): The maximum number of operations after which an intermediate commit is performed automatically.
-
skipInaccessibleCollections (boolean, optional): Let AQL queries (especially graph traversals) treat collection to which a user has no access rights for as if these collections are empty. Instead of returning a forbidden access error, your queries execute normally. This is intended to help with certain use-cases: A graph contains several collections and different users execute AQL queries on that graph. You can naturally limit the accessible results by changing the access rights of users on collections.
This feature is only available in the Enterprise Edition.
-
allowDirtyReads (boolean, optional): If you set this option to
true
and execute the query against a cluster deployment, then the Coordinator is allowed to read from any shard replica and not only from the leader.You may observe data inconsistencies (dirty reads) when reading from followers, namely obsolete revisions of documents because changes have not yet been replicated to the follower, as well as changes to documents before they are officially committed on the leader.
This feature is only available in the Enterprise Edition.
-
The query details include the query string plus optional query options and bind parameters. These values need to be passed in a JSON representation in the body of the POST request.
Responses
HTTP 201: is returned if the result set can be created by the server.
-
error (boolean): A flag to indicate that an error occurred (
false
in this case). -
code (integer): The HTTP status code.
-
result (array): An array of result documents (might be empty if query has no results).
-
hasMore (boolean): A boolean indicator whether there are more results available for the cursor on the server.
-
count (integer): The total number of result documents available (only available if the query was executed with the
count
attribute set). -
id (string): The ID of a temporary cursor created on the server for fetching more result batches.
-
extra (object): An optional JSON object with extra information about the query result.
-
warnings (array): A list of query warnings.
-
code (integer): An error code.
-
message (string): A description of the problem.
-
-
stats (object): An object with query statistics.
-
writesExecuted (integer): The total number of data-modification operations successfully executed.
-
writesIgnored (integer): The total number of data-modification operations that were unsuccessful, but have been ignored because of the
ignoreErrors
query option. -
scannedFull (integer): The total number of documents iterated over when scanning a collection without an index. Documents scanned by subqueries are included in the result, but operations triggered by built-in or user-defined AQL functions are not.
-
scannedIndex (integer): The total number of documents iterated over when scanning a collection using an index. Documents scanned by subqueries are included in the result, but operations triggered by built-in or user-defined AQL functions are not.
-
cursorsCreated (integer): The total number of cursor objects created during query execution. Cursor objects are created for index lookups.
-
cursorsRearmed (integer): The total number of times an existing cursor object was repurposed. Repurposing an existing cursor object is normally more efficient compared to destroying an existing cursor object and creating a new one from scratch.
-
cacheHits (integer): The total number of index entries read from in-memory caches for indexes of type edge or persistent. This value is only non-zero when reading from indexes that have an in-memory cache enabled, and when the query allows using the in-memory cache (i.e. using equality lookups on all index attributes).
-
cacheMisses (integer): The total number of cache read attempts for index entries that could not be served from in-memory caches for indexes of type edge or persistent. This value is only non-zero when reading from indexes that have an in-memory cache enabled, the query allows using the in-memory cache (i.e. using equality lookups on all index attributes) and the looked up values are not present in the cache.
-
filtered (integer): The total number of documents removed after executing a filter condition in a
FilterNode
or another node that post-filters data. Note that nodes of theIndexNode
type can also filter documents by selecting only the required index range from a collection, and thefiltered
value only indicates how much filtering was done by a post filter in theIndexNode
itself or followingFilterNode
nodes. Nodes of theEnumerateCollectionNode
andTraversalNode
types can also apply filter conditions and can report the number of filtered documents. -
httpRequests (integer): The total number of cluster-internal HTTP requests performed.
-
fullCount (integer): The total number of documents that matched the search condition if the query’s final top-level
LIMIT
operation were not present. This attribute may only be returned if thefullCount
option was set when starting the query and only contains a sensible value if the query contains aLIMIT
operation on the top level. -
executionTime (number): The query execution time (wall-clock time) in seconds.
-
peakMemoryUsage (integer): The maximum memory usage of the query while it was running. In a cluster, the memory accounting is done per shard, and the memory usage reported is the peak memory usage value from the individual shards. Note that to keep things lightweight, the per-query memory usage is tracked on a relatively high level, not including any memory allocator overhead nor any memory used for temporary results calculations (e.g. memory allocated/deallocated inside AQL expressions and function calls).
-
nodes (array): When the query is executed with the
profile
option set to at least2
, then this attribute contains runtime statistics per query execution node. For a human readable output, you can executedb._profileQuery(<query>, <bind-vars>)
in arangosh.-
id (integer): The execution node ID to correlate the statistics with the
plan
returned in theextra
attribute. -
calls (integer): The number of calls to this node.
-
items (integer): The number of items returned by this node. Items are the temporary results returned at this stage.
-
runtime (number): The execution time of this node in seconds.
-
-
-
profile (object): The duration of the different query execution phases in seconds.
- initializing (number):
- parsing (number):
- optimizing ast (number):
- loading collections (number):
- instantiating plan (number):
- optimizing plan (number):
- executing (number):
- finalizing (number):
-
plan (object): The execution plan.
-
nodes (array of objects): A nested list of the execution plan nodes.
-
rules (array of strings): A list with the names of the applied optimizer rules.
-
collections (array): A list of the collections involved in the query. The list only includes the collections that can statically be determined at query compile time.
-
name (string): The collection name.
-
type (string): How the collection is used. Can be
"read"
,"write"
, or"exclusive"
.
-
-
variables (array of objects): All of the query variables, including user-created and internal ones.
-
estimatedCost (integer): The estimated cost of the query.
-
estimatedNrItems (integer): The estimated number of results.
-
isModificationQuery (boolean): Whether the query contains write operations.
-
-
-
cached (boolean): A boolean flag indicating whether the query result was served from the query cache or not. If the query result is served from the query cache, the
extra
return attribute will not contain anystats
sub-attribute and noprofile
sub-attribute.
HTTP 400: is returned if the JSON representation is malformed or the query specification is missing from the request.
If the JSON representation is malformed or the query specification is missing from the request, the server will respond with HTTP 400.
The body of the response will contain a JSON object with additional error details. The object has the following attributes:
-
error (boolean): boolean flag to indicate that an error occurred (true in this case)
-
code (integer): the HTTP status code
-
errorNum (integer): the server error number
-
errorMessage (string): A descriptive error message.
If the query specification is complete, the server will process the query. If an error occurs during query processing, the server will respond with HTTP 400. Again, the body of the response will contain details about the error.
HTTP 404: The server will respond with HTTP 404 in case a non-existing collection is accessed in the query.
HTTP 405: The server will respond with HTTP 405 if an unsupported HTTP method is used.
HTTP 410: The server will respond with HTTP 410 if a server which processes the query or is the leader for a shard which is used in the query stops responding, but the connection has not been closed.
HTTP 503: The server will respond with HTTP 503 if a server which processes the query or is the leader for a shard which is used in the query is down, either for going through a restart, a failure or connectivity issues.
Examples
Execute a query and extract the result in a single go
shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/cursor <<EOF
{
"query" : "FOR p IN products LIMIT 2 RETURN p",
"count" : true,
"batchSize" : 2
}
EOF
HTTP/1.1 201 Created
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 495
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Execute a query and extract a part of the result
shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/cursor <<EOF
{
"query" : "FOR p IN products LIMIT 5 RETURN p",
"count" : true,
"batchSize" : 2
}
EOF
HTTP/1.1 201 Created
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 507
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Using the query option “fullCount”
shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/cursor <<EOF
{
"query" : "FOR i IN 1..1000 FILTER i > 500 LIMIT 10 RETURN i",
"count" : true,
"options" : {
"fullCount" : true
}
}
EOF
HTTP/1.1 201 Created
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 401
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Enabling and disabling optimizer rules
shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/cursor <<EOF
{
"query" : "FOR i IN 1..10 LET a = 1 LET b = 2 FILTER a + b == 3 RETURN i",
"count" : true,
"options" : {
"maxPlans" : 1,
"optimizer" : {
"rules" : [
"-all",
"+remove-unnecessary-filters"
]
}
}
}
EOF
HTTP/1.1 201 Created
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 358
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Execute instrumented query and return result together with execution plan and profiling information
shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/cursor <<EOF
{
"query" : "LET s = SLEEP(0.25) LET t = SLEEP(0.5) RETURN 1",
"count" : true,
"options" : {
"profile" : 2
}
}
EOF
HTTP/1.1 201 Created
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 2890
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Execute a data-modification query and retrieve the number of modified documents
shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/cursor <<EOF
{
"query" : "FOR p IN products REMOVE p IN products"
}
EOF
HTTP/1.1 201 Created
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 329
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Execute a data-modification query with option ignoreErrors
shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/cursor <<EOF
{
"query" : "REMOVE 'bar' IN products OPTIONS { ignoreErrors: true }"
}
EOF
HTTP/1.1 201 Created
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 328
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Bad query - Missing body
shell> curl -X POST --header 'accept: application/json' --dump - http://localhost:8529/_api/cursor
HTTP/1.1 400 Bad Request
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 73
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Bad query - Unknown collection
shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/cursor <<EOF
{
"query" : "FOR u IN unknowncoll LIMIT 2 RETURN u",
"count" : true,
"batchSize" : 2
}
EOF
HTTP/1.1 404 Not Found
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 121
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Bad query - Execute a data-modification query that attempts to remove a non-existing document
shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/cursor <<EOF
{
"query" : "REMOVE 'foo' IN products"
}
EOF
HTTP/1.1 404 Not Found
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 100
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Read next batch from cursor
return the next results from an existing cursor
POST /_api/cursor/{cursor-identifier}
Path Parameters
- cursor-identifier (string, required): The name of the cursor
If the cursor is still alive, returns an object with the following attributes:
- id: a cursor-identifier
- result: a list of documents for the current batch
- hasMore: false if this was the last batch
- count: if present the total number of elements
- code: an HTTP status code
- error: a boolean flag to indicate whether an error occurred
- errorNum: a server error number (if error is true)
- errorMessage: a descriptive error message (if error is true)
- extra: an object with additional information about the query result, with the nested objects stats and warnings. Only delivered as part of the last batch in case of a cursor with the stream option enabled.
Note that even if hasMore returns true, the next call might still return no documents. If, however, hasMore is false, then the cursor is exhausted. Once the hasMore attribute has a value of false, the client can stop.
Responses
HTTP 200: The server will respond with HTTP 200 in case of success.
HTTP 400: If the cursor identifier is omitted, the server will respond with HTTP 404.
HTTP 404: If no cursor with the specified identifier can be found, the server will respond with HTTP 404.
HTTP 410: The server will respond with HTTP 410 if a server which processes the query or is the leader for a shard which is used in the query stops responding, but the connection has not been closed.
HTTP 503: The server will respond with HTTP 503 if a server which processes the query or is the leader for a shard which is used in the query is down, either for going through a restart, a failure or connectivity issues.
Examples
Valid request for next batch
shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/cursor <<EOF
{
"query" : "FOR p IN products LIMIT 5 RETURN p",
"count" : true,
"batchSize" : 2
}
EOF
shell> curl -X POST --header 'accept: application/json' --dump - http://localhost:8529/_api/cursor/69175
HTTP/1.1 200 OK
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 507
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Missing identifier
shell> curl -X POST --header 'accept: application/json' --dump - http://localhost:8529/_api/cursor
HTTP/1.1 400 Bad Request
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 73
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Unknown identifier
shell> curl -X POST --header 'accept: application/json' --dump - http://localhost:8529/_api/cursor/123123
HTTP/1.1 404 Not Found
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 75
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Read next batch from cursor (deprecated)
return the next results from an existing cursor
PUT /_api/cursor/{cursor-identifier}
This endpoint is deprecated in favor its functionally equivalent POST counterpart.
Path Parameters
- cursor-identifier (string, required): The name of the cursor
If the cursor is still alive, returns an object with the following attributes:
- id: a cursor-identifier
- result: a list of documents for the current batch
- hasMore: false if this was the last batch
- count: if present the total number of elements
- code: an HTTP status code
- error: a boolean flag to indicate whether an error occurred
- errorNum: a server error number (if error is true)
- errorMessage: a descriptive error message (if error is true)
- extra: an object with additional information about the query result, with the nested objects stats and warnings. Only delivered as part of the last batch in case of a cursor with the stream option enabled.
Note that even if hasMore returns true, the next call might still return no documents. If, however, hasMore is false, then the cursor is exhausted. Once the hasMore attribute has a value of false, the client can stop.
Responses
HTTP 200: The server will respond with HTTP 200 in case of success.
HTTP 400: If the cursor identifier is omitted, the server will respond with HTTP 404.
HTTP 404: If no cursor with the specified identifier can be found, the server will respond with HTTP 404.
HTTP 410: The server will respond with HTTP 410 if a server which processes the query or is the leader for a shard which is used in the query stops responding, but the connection has not been closed.
HTTP 503: The server will respond with HTTP 503 if a server which processes the query or is the leader for a shard which is used in the query is down, either for going through a restart, a failure or connectivity issues.
Examples
Valid request for next batch
shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/cursor <<EOF
{
"query" : "FOR p IN products LIMIT 5 RETURN p",
"count" : true,
"batchSize" : 2
}
EOF
shell> curl -X PUT --header 'accept: application/json' --dump - http://localhost:8529/_api/cursor/69150
HTTP/1.1 200 OK
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 507
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Missing identifier
shell> curl -X PUT --header 'accept: application/json' --dump - http://localhost:8529/_api/cursor
HTTP/1.1 400 Bad Request
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 97
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Unknown identifier
shell> curl -X PUT --header 'accept: application/json' --dump - http://localhost:8529/_api/cursor/123123
HTTP/1.1 404 Not Found
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 75
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Delete cursor
dispose an existing cursor
DELETE /_api/cursor/{cursor-identifier}
Path Parameters
- cursor-identifier (string, required): The id of the cursor
Deletes the cursor and frees the resources associated with it.
The cursor will automatically be destroyed on the server when the client has retrieved all documents from it. The client can also explicitly destroy the cursor at any earlier time using an HTTP DELETE request. The cursor id must be included as part of the URL.
Note: the server will also destroy abandoned cursors automatically after a certain server-controlled timeout to avoid resource leakage.
Responses
HTTP 202: is returned if the server is aware of the cursor.
HTTP 404: is returned if the server is not aware of the cursor. It is also returned if a cursor is used after it has been destroyed.
Examples
shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/cursor <<EOF
{
"query" : "FOR p IN products LIMIT 5 RETURN p",
"count" : true,
"batchSize" : 2
}
EOF
HTTP/1.1 201 Created
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 506
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
shell> curl -X DELETE --header 'accept: application/json' --dump - http://localhost:8529/_api/cursor/69097