ArangoDB Manual Pages


Accessing Skip-List Indexes via Http
If a suitable skip-list index exists, then /_api/simple/range will use this index to execute a range query.

POST /_api/index
(creates a hash index)
POST /_api/index?collection=collection-name
Creates a skip-list index for the collection collection-name, if it does not already exist. The call expects an object containing the index details.
  • type: must be equal to "skiplist".
  • fields: A list of attribute paths.
  • unique: If true, then create a unique index.
If the index does not already exist and could be created, then a HTTP 201 is returned. If the index already exists, then a HTTP 200 is returned.If the collection-name is unknown, then a HTTP 404 is returned.If the collection already contains documents and you try to create a unique skip-list index in such a way that there are documents violating the uniqueness, then a HTTP 400 is returned.
Examples
Creating a skiplist:
> curl --data @- -X POST --dump - http://localhost:8529/_api/index?collection=109061392
{ "type" : "skiplist", "unique" : false, "fields" : [ "a", "b" ] }

HTTP/1.1 201 Created
content-type: application/json

{
  "code": 201,
  "fields": [
    "a",
    "b"
  ],
  "id": "109061392/173166777",
  "type": "skiplist",
  "isNewlyCreated": true,
  "unique": false,
  "error": false
}

PUT /_api/simple/range
(executes simple range query)
PUT /_api/simple/range
This will find all documents within a given range. You must declare a skip-list index on the attribute in order to be able to use a range query.The call expects a JSON hash array as body with the following attributes:
  • collection: The name of the collection to query.
  • attribute: The attribute path to check.
  • left: The lower bound.
  • right: The upper bound.
  • closed: If true, use interval including left and right, otherwise exclude right, but include left.
  • skip: The documents to skip in the query. (optional)
  • limit: The maximal amount of documents to return. (optional)
Returns a cursor containing the result, see HTTP Interface for AQL Query Cursors for details.
Examples
> curl --data @- -X PUT --dump - http://localhost:8529/_api/simple/range
{ "collection" : "6328369086", "attribute" : "i", "left" : 2, "right" : 4 }

HTTP/1.1 201 Created
content-type: application/json

{
  "code": 201,
  "result": [
    { "_id": "6328369086/6329876414", "i": 2, "_rev": "6329876414" },
    { "_id": "6328369086/6329941950", "i": 3, "_rev": "6329941950" }
  ],
  "count": 2,
  "hasMore": false,
  "error": false
}