ArangoDB v4.x is under development and not released yet.
This documentation is not final and potentially incomplete.
TTL (time-to-live) index HTTP API
HTTP interface reference for creating indexes of type ttl
Create a TTL index
POST http://<EXTERNAL_ENDPOINT>:8529/_arango/v1/_db/:database-name/_api/index
Creates a time-to-live (TTL) index for the collection
collection-name if it
does not already exist.HTTP Headers
Request Body application/json object
expireAfter number, required
The time interval (in seconds) from the point in time stored in the
fieldsattribute after which the documents count as expired. Can be set to0to let documents expire as soon as the server time passes the point in time stored in the document attribute, or to a higher number to delay the expiration.
Examples
Creating a TTL index
curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/index?collection=sessions
{
"type": "ttl",
"expireAfter": 3600,
"fields": [
"createdAt"
]
}Show output
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: 205
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
{
"estimates" : false,
"expireAfter" : 3600,
"fields" : [
"createdAt"
],
"id" : "sessions/69689",
"isNewlyCreated" : true,
"name" : "idx_1793257748845035520",
"sparse" : true,
"type" : "ttl",
"unique" : false,
"code" : 201,
"error" : false
}