ArangoDB Manual Pages


HTTP Interface for Indexes

Indexes

This is an introduction to ArangoDB's Http interface for indexes in general. There are special sections for various index types.

Index: Indexes are used to allow fast access to documents. For each collection there is always the primary index which is a hash index for the document key.

Index Handle: An index handle uniquely identifies an index in the database. It is a string and consists of a collection name and an index identifier separated by /.

Geo Index: A geo index is used to find places on the surface of the earth fast.

Hash Index: A hash index is used to find documents based on examples.

Edges Index: An edges index is automatically created for edge collections. It contains connections between vertex documents and is invoked when the connecting edges of a vertex are queried. There is no way to explicitly create or delete edge indexes.

Skiplist Index: A skiplist is used to find ranges of documents.

Fulltext Index: A fulltext index can be used to find words, or prefixes of words inside documents. A fulltext index can be set on one attribute only, and will index all words contained in documents that have a textual value in this attribute. Only words with a (specifyable) minimum length are indexed. Word tokenisation is done using the word boundary analysis provided by libicu, which is taking into account the selected language provided at server start. Words are indexed in their lower-cased form. The index supports complete match queries (full words) and prefix queries.

The basic operations (create, read, update, delete) for documents are mapped to the standard HTTP methods (POST, GET, PUT, DELETE).

Address of an Index

All indexes in ArangoDB have an unique handle. This index handle identifies an index and is managed by ArangoDB. All indexes are found under the URI

http://server:port/_api/index/index-handle

For example: Assume that the index handle is demo/63563528 then the URL of that index is:

http://localhost:8529/_api/index/demo/63563528

Working with Indexes using HTTP

GET /_api/index
(reads an index)
GET /_api/index/index-handle
The result is an objects describing the index. It has at least the following attributes:
  • id: The identifier of the index.
  • type: The type of the collection.
All other attributes are type-dependent.
Examples
> curl -X GET --dump - http://localhost:8529/_api/index/117843216/0

HTTP/1.1 200 OK
content-type: application/json

{
  "code": 200,
  "fields": [
    "_id"
  ],
  "id": "117843216/0",
  "type": "primary",
  "error": false
}

POST /_api/index
(creates an index)
POST /_api/index?collection=collection-name
Creates a new index in the collection collection-name. Expects an object containing the index details.See Accessing Cap Constraints via Http, Accessing Geo Indexes via Http, Accessing Hash Indexes via Http, Accessing Fulltext Indexes via Http, and Accessing Skip-List Indexes via Http for details.By default, non-unique indexes will be created. To change this, use the unique attribute in the index details and set its value to true.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.
Examples
Creating a unique constraint:
> curl --data @- -X POST --dump - http://localhost:8529/_api/index?collection=102901008
{ "type" : "hash", "unique" : true, "fields" : [ "a", "b" ] }

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

{
  "code": 201,
  "fields": [
    "a",
    "b"
  ],
  "id": "102901008/168054969",
  "type": "hash",
  "isNewlyCreated": true,
  "unique": true,
  "error": false
}
Creating a hash index:
> curl --data @- -X POST --dump - http://localhost:8529/_api/index?collection=105981200
{ "type" : "hash", "unique" : false, "fields" : [ "a", "b" ] }

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

{
  "code": 201,
  "fields": [
    "a",
    "b"
  ],
  "id": "105981200/171069625",
  "type": "hash",
  "isNewlyCreated": true,
  "unique": false,
  "error": false
}
Creating a skip-list:
> 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
}
Creating a unique skip-list:
> curl --data @- -X POST --dump - http://localhost:8529/_api/index?collection=112141584
{ "type" : "skiplist", "unique" : true, "fields" : [ "a", "b" ] }

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

{
  "code": 201,
  "fields": [
    "a",
    "b"
  ],
  "id": "112141584/175722681",
  "type": "skiplist",
  "isNewlyCreated": true,
  "unique": true,
  "error": false
}
Creating a fulltext index:
> curl --data @- -X POST --dump - http://localhost:8529/_api/index?collection=109061392
{ "type" : "fulltext", "fields" : [ "text" ] }

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

{
  "code": 201,
  "fields": [
    "text"
  ],
  "id": "109061392/1748352392",
  "type": "fulltext",
  "isNewlyCreated": true,
  "error": false
}

DELETE /_api/index
(deletes an index)
DELETE /_api/index/index-handle
Deletes an index with index-handle.
Examples
> curl -X DELETE --dump - http://localhost:8529/_api/index/180506809/181424313

HTTP/1.1 200 OK
content-type: application/json

{
  "code": 200,
  "id": "180506809/181424313",
  "error": false
}

GET /_api/index
(reads all indexes of a collection)
GET /_api/index?collection=collection-name
Returns an object with an attribute indexes containing a list of all index descriptions for the given collection. The same information is also available in the identifiers as hash map with the index handle as keys.
Examples
Return information about all indexes:
> curl -X GET --dump - http://localhost:8529/_api/index?collection=115221776

HTTP/1.1 200 OK
content-type: application/json

{
  "code": 200,
  "indexes": [
    {
      "fields": [
        "_id"
      ],
      "id": "115221776/0",
      "type": "primary"
    }
  ],
  "error": false,
  "identifiers": {
    "115221776/0": {
      "fields": [
        "_id"
      ],
      "id": "115221776/0",
      "type": "primary"
    }
  }
}