ArangoDB v2.8 reached End of Life (EOL) and is no longer supported.
This documentation is outdated. Please see the most recent version here: Try latest
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 --data-binary @- --dump - http://localhost:8529/_api/index?collection=products <<EOF
{
"type" : "fulltext",
"fields" : [
"text"
]
}
EOF
HTTP/1.1 201 Created
content-type: application/json; charset=utf-8
{
"id" : "products/780290177",
"type" : "fulltext",
"fields" : [
"text"
],
"unique" : false,
"sparse" : true,
"minLength" : 2,
"isNewlyCreated" : true,
"error" : false,
"code" : 201
}
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/index?collection=products <<EOF
{
"type" : "fulltext",
"fields" : [
"text"
]
}
EOF
HTTP/1.1 201 Created
content-type: application/json; charset=utf-8
Fulltext index query
returns documents of a collection as a result of a fulltext query
PUT /_api/simple/fulltext
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 --data-binary @- --dump - http://localhost:8529/_api/simple/fulltext <<EOF
{
"collection" : "products",
"attribute" : "text",
"query" : "word"
}
EOF
HTTP/1.1 201 Created
content-type: application/json; charset=utf-8
{
"result" : [
{
"_id" : "products/813516929",
"_key" : "813516929",
"_rev" : "813516929",
"text" : "this text also has a word"
},
{
"_id" : "products/813320321",
"_key" : "813320321",
"_rev" : "813320321",
"text" : "this text contains word"
}
],
"hasMore" : false,
"count" : 2,
"error" : false,
"code" : 201
}
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/simple/fulltext <<EOF
{
"collection" : "products",
"attribute" : "text",
"query" : "word"
}
EOF
HTTP/1.1 201 Created
content-type: application/json; charset=utf-8