Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 955 Bytes

File metadata and controls

52 lines (40 loc) · 955 Bytes
endpoint terms_enum
lang python
es_version 9.3
client elasticsearch==9.3.0

Elasticsearch 9.3 terms_enum endpoint (Python example)

Use client.terms_enum() to retrieve terms matching a prefix from a keyword field. This is designed for autocomplete and typeahead use cases:

response = client.terms_enum(
    index="products",
    field="category.keyword",
    string="e",
)

print(f"Suggestions: {response['terms']}")

Limiting results

Use size to control how many terms are returned:

response = client.terms_enum(
    index="products",
    field="name.keyword",
    size=5,
)

for term in response["terms"]:
    print(f"  {term}")

Case-insensitive matching

Set case_insensitive=True to match regardless of case:

response = client.terms_enum(
    index="products",
    field="category.keyword",
    string="E",
    case_insensitive=True,
)

print(f"Matches: {response['terms']}")