Get terms in an index
Generally available; Added in 7.14.0
All methods and paths for this operation:
Discover terms that match a partial string in an index. This API is designed for low-latency look-ups used in auto-complete scenarios.
The terms enum API may return terms from deleted documents. Deleted documents are initially only marked as deleted. It is not until their segments are merged that documents are actually deleted. Until that happens, the terms enum API will return terms from these documents.
Path parameters
-
A comma-separated list of data streams, indices, and index aliases to search. Wildcard (
*
) expressions are supported. To search all data streams or indices, omit this parameter or use*
or_all
.
Body
-
The string to match at the start of indexed terms. If not provided, all terms in the field are considered.
-
The number of matching terms to return.
Default value is
10
. -
The maximum length of time to spend collecting results. If the timeout is exceeded the
complete
flag set tofalse
in the response and the results may be partial or empty. -
When
true
, the provided search string is matched against index terms without case sensitivity.Default value is
false
. -
Filter an index shard if the provided query rewrites to
match_none
.External documentation -
The string to match at the start of indexed terms. If it is not provided, all terms in the field are considered.
The prefix string cannot be larger than the largest possible keyword value, which is Lucene's term byte-length limit of 32766.
-
The string after which terms in the index should be returned. It allows for a form of pagination if the last result from one request is passed as the
search_after
parameter for a subsequent request.
POST stackoverflow/_terms_enum
{
"field" : "tags",
"string" : "kiba"
}
resp = client.terms_enum(
index="stackoverflow",
field="tags",
string="kiba",
)
const response = await client.termsEnum({
index: "stackoverflow",
field: "tags",
string: "kiba",
});
response = client.terms_enum(
index: "stackoverflow",
body: {
"field": "tags",
"string": "kiba"
}
)
$resp = $client->termsEnum([
"index" => "stackoverflow",
"body" => [
"field" => "tags",
"string" => "kiba",
],
]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"field":"tags","string":"kiba"}' "$ELASTICSEARCH_URL/stackoverflow/_terms_enum"
client.termsEnum(t -> t
.field("tags")
.index("stackoverflow")
.string("kiba")
);
{
"field" : "tags",
"string" : "kiba"
}
{
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"terms": [
"kibana"
],
"complete" : true
}