Skip to content

Commit dd273b0

Browse files
Execution hint documentation added to cardinality agg (#9224) (#9316)
1 parent fe0a886 commit dd273b0

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

_aggregations/metric/cardinality.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,40 @@ GET opensearch_dashboards_sample_data_ecommerce/_search
5858
}
5959
}
6060
}
61-
```
61+
```
62+
{% include copy-curl.html %}
63+
64+
## Configuring aggregation execution
65+
66+
You can control how an aggregation runs using the `execution_hint` setting. This setting supports two options:
67+
68+
- `direct` – Uses field values directly.
69+
- `ordinals` – Uses ordinals of the field.
70+
71+
If you don't specify `execution_hint`, OpenSearch automatically chooses the best option for the field.
72+
73+
Setting `ordinals` on a non-ordinal field has no effect. Similarly, `direct` has no effect on ordinal fields.
74+
{: .note}
75+
76+
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.
77+
{: .warning}
78+
79+
### Example
80+
81+
The following request runs a cardinality aggregation using ordinals:
82+
83+
```json
84+
GET opensearch_dashboards_sample_data_ecommerce/_search
85+
{
86+
"size": 0,
87+
"aggs": {
88+
"unique_products": {
89+
"cardinality": {
90+
"field": "products.product_id",
91+
"execution_hint": "ordinals"
92+
}
93+
}
94+
}
95+
}
96+
```
97+
{% include copy-curl.html %}

0 commit comments

Comments
 (0)