Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution hint documentation added to cardinality agg #9224

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion _aggregations/metric/cardinality.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,40 @@ GET opensearch_dashboards_sample_data_ecommerce/_search
}
}
}
```
```
{% include copy-curl.html %}

## Configuring aggregation execution

You can control how an aggregation runs using the `execution_hint` setting. This setting supports two options:

- `direct` – Uses field values directly.
- `ordinals` – Uses ordinals of the field.

If you don’t specify `execution_hint`, OpenSearch automatically chooses the best option for the field.

Setting `ordinals` on a non-ordinal field has no effect. Similarly, `direct` has no effect on ordinal fields.
{: .note}

This is an expert-level setting. Ordinals use byte arrays, where the array size depends on the field's cardinality. High-cardinality fields can consume significant heap memory, increasing the risk of out-of-memory errors.
{: .warning}

### Example

The following request runs a cardinality aggregation using ordinals:

```json
GET opensearch_dashboards_sample_data_ecommerce/_search
{
"size": 0,
"aggs": {
"unique_products": {
"cardinality": {
"field": "products.product_id",
"execution_hint": "ordinals"
}
}
}
}
```
{% include copy-curl.html %}