Error when using a search index: field:xx must enable enable_sort_and_agg

Updated at:

Symptoms

When you use the sorting or aggregation feature of a search index, the following error is reported:

Message: Search engine: [groupby_field] field:xx must enable enable_sort_and_agg, but enable_sort_and_agg is not enabled

Cause

The sorting and aggregation feature was not enabled for the field when the search index was created because the enable_sort_and_agg parameter was not set to true.

Solution

You can enable the sorting and aggregation feature for the field using the dynamic schema update feature of the search index. For more information, see Dynamically modify a schema.