Get terms in an index Generally available; Added in 7.14.0

POST /{index}/_terms_enum

All methods and paths for this operation:

GET /{index}/_terms_enum

POST /{index}/_terms_enum

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

  • index string Required

    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.

application/json

Body

  • field string Required

    The string to match at the start of indexed terms. If not provided, all terms in the field are considered.

  • size number

    The number of matching terms to return.

    Default value is 10.

  • timeout string

    The maximum length of time to spend collecting results. If the timeout is exceeded the complete flag set to false in the response and the results may be partial or empty.

  • case_insensitive boolean

    When true, the provided search string is matched against index terms without case sensitivity.

    Default value is false.

  • index_filter object

    Filter an index shard if the provided query rewrites to match_none.

    External documentation
  • string string

    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.

  • search_after string

    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.

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • _shards object Required
      Hide _shards attributes Show _shards attributes object
      • failed number Required

        The number of shards the operation or search attempted to run on but failed.

      • successful number Required

        The number of shards the operation or search succeeded on.

      • total number Required

        The number of shards the operation or search will run on overall.

      • failures array[object]
        Hide failures attributes Show failures attributes object
        • index string
        • node string
        • reason object Required

          Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.

        • shard number
        • status string
        • primary boolean
      • skipped number
    • terms array[string] Required
    • complete boolean Required

      If false, the returned terms set may be incomplete and should be treated as approximate. This can occur due to a few reasons, such as a request timeout or a node error.

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")
);
Request example
Run `POST stackoverflow/_terms_enum`.
{
    "field" : "tags",
    "string" : "kiba"
}
Response examples (200)
A successful response from `POST stackoverflow/_terms_enum`.
{
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "terms": [
    "kibana"
  ],
  "complete" : true
}