Skip to content

Latest commit

 

History

History
51 lines (39 loc) · 1.06 KB

File metadata and controls

51 lines (39 loc) · 1.06 KB
endpoint terms_enum
lang dotnet
es_version 9.3
client Elastic.Clients.Elasticsearch==9.3.0

Elasticsearch 9.3 terms_enum endpoint (.NET example)

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

var response = await client.TermsEnumAsync("products", t => t
    .Field("category.keyword")
    .String("e")
);

Console.WriteLine($"Suggestions: {string.Join(", ", response.Terms)}");

Limiting results

Use Size to control how many terms are returned:

var response = await client.TermsEnumAsync("products", t => t
    .Field("name.keyword")
    .Size(5)
);

foreach (var term in response.Terms)
{
    Console.WriteLine($"  {term}");
}

Case-insensitive matching

Set CaseInsensitive to match regardless of case:

var response = await client.TermsEnumAsync("products", t => t
    .Field("category.keyword")
    .String("E")
    .CaseInsensitive(true)
);

Console.WriteLine($"Matches: {string.Join(", ", response.Terms)}");