Fulltext

If a fulltext index exists, then /_api/simple/fulltext will use this index to execute the specified fulltext query.

Create fulltext index

creates a fulltext index

POST /_api/index#fulltext

Query Parameters

  • collection-name (required): The collection name.

A JSON object with these properties is required:

  • type: must be equal to “fulltext”.

  • fields: an array of attribute names. Currently, the array is limited to exactly one attribute.

  • 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.

NOTE Swagger examples won’t work due to the anchor.

Creates a fulltext index for the collection collection-name, if it does not already exist. The call expects an object containing the index details.

Return codes

  • 200: If the index already exists, then a HTTP 200 is returned.

  • 201: If the index does not already exist and could be created, then a HTTP 201 is returned.

  • 404: If the collection-name is unknown, then a HTTP 404 is returned.

Examples

Creating a fulltext index

shell> curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/index?collection=products <<EOF
{ 
  "type" : "fulltext", 
  "fields" : [ 
    "text" 
  ] 
}
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body

Fulltext index query

returns documents of a collection as a result of a fulltext query

PUT /_api/simple/fulltext

This route should no longer be used. All endpoints for Simple Queries are deprecated from version 3.4.0 on. They are superseded by AQL queries.

A JSON object with these properties is required:

  • collection: The name of the collection to query.

  • attribute: The attribute that contains the texts.

  • query: The fulltext query. Please refer to Fulltext queries for details.

  • skip: The number of documents to skip in the query (optional).

  • limit: The maximal amount of documents to return. The skip is applied before the limit restriction. (optional)

  • index: The identifier of the fulltext-index to use.

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.

Returns a cursor containing the result, see HTTP Cursor for details.

Note: the fulltext simple query is deprecated as of ArangoDB 2.6. This API may be removed in future versions of ArangoDB. The preferred way for retrieving documents from a collection using the near operator is to issue an AQL query using the FULLTEXT AQL function as follows:

FOR doc IN FULLTEXT(@@collection, @attributeName, @queryString, @limit) 
  RETURN doc

Return codes

  • 201: is returned if the query was executed successfully.

  • 400: is returned if the body does not contain a valid JSON representation of a query. The response body contains an error document in this case.

  • 404: is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

Examples

shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/simple/fulltext <<EOF
{ 
  "collection" : "products", 
  "attribute" : "text", 
  "query" : "word" 
}
EOF

HTTP/1.1 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

Show response body