ArangoDB Manual Pages


Accessing Fulltext Indexes via Http
If a fulltext index exists, then /_api/simple/fulltext will use this index to execute the specified fulltext query.

POST /_api/index
(creates a fulltext index)
POST /_api/index?collection=collection-name
Creates a fulltext 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 "fulltext".
  • fields: A list of attribute names. Currently, the list is limited to exactly one attribute, so the value of fields should look like this for example: [ "text" ].
  • minLength: Minimum character length of words to index. Will default to a server-defined value if unspecified. It is thus recommended to set this value explicitly when creating the 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.
Examples
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
}

PUT /_api/simple/fulltext
(executes simple query "fulltext")
PUT /_api/simple/fulltext
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.The call expects a JSON hash array as body with the following attributes:
  • collection: The name of the collection to query.
  • attribute: The attribute that contains the texts.
  • query: The fulltext query.
  • skip: The documents to skip in the query. (optional)
  • limit: The maximal amount of documents to return. (optional)
  • index: If given, the identifier of the fulltext-index to use. (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/fulltext
{ "collection" : "2076584128", "attribute" : "text", "query" : "word" }

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

{
  "result": [
    {
      "_id": "2076584128/2082744512",
      "text" : "this text contains a word",
      "_rev": "2082744512"
    },
    {
      "_id": "2076584128/2082089152",
      "text" : "this text also contains a word",
      "loc": [ 0, 10 ],
      "_rev": "2082089152"
    }
  ],
  "code": 201,
  "hasMore": false,
  "count": 2,
  "error": false
}