ArangoDB v3.4 reached End of Life (EOL) and is no longer supported.
This documentation is outdated. Please see the most recent version here: Latest Docs
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
Query Parameters
- collection-name (string, required): The collection name.
Request Body
-
type (string, required): must be equal to “fulltext”.
-
fields (array of strings, required): an array of attribute names. Currently, the array is limited to exactly one attribute.
-
minLength (integer, required): 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.
Responses
HTTP 200: If the index already exists, then a HTTP 200 is returned.
HTTP 201: If the index does not already exist and could be created, then a HTTP 201 is returned.
HTTP 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
{
"fields" : [
"text"
],
"id" : "products/69767",
"isNewlyCreated" : true,
"minLength" : 2,
"sparse" : true,
"type" : "fulltext",
"unique" : false,
"error" : false,
"code" : 201
}
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
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.
Request Body
-
collection (string, required): The name of the collection to query.
-
attribute (string, required): The attribute that contains the texts.
-
query (string, required): The fulltext query. Please refer to Fulltext queries for details.
-
skip (string, required): The number of documents to skip in the query (optional).
-
limit (string, required): The maximal amount of documents to return. The skip is applied before the limit restriction. (optional)
-
index (string, required): 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
Responses
HTTP 201: is returned if the query was executed successfully.
HTTP 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.
HTTP 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
{
"result" : [
{
"_key" : "70057",
"_id" : "products/70057",
"_rev" : "_bHcRMaq---",
"text" : "this text contains word"
},
{
"_key" : "70059",
"_id" : "products/70059",
"_rev" : "_bHcRMau---",
"text" : "this text also has a word"
}
],
"hasMore" : false,
"count" : 2,
"error" : false,
"code" : 201
}
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