Skip to content

Commit 01c495b

Browse files
asimmahmood1maitreya2954kolchfa-awsnatebower
authored andcommitted
Execution hint documentation added to cardinality agg (opensearch-project#9224)
* Execution hint documentation added to cardinality agg Signed-off-by: Siddharth Rayabharam <[email protected]> * Add expert level warning to cardinality execution_hint paramter Signed-off-by: Asim Mahmood <[email protected]> * Doc review Signed-off-by: Fanit Kolchina <[email protected]> * Update _aggregations/metric/cardinality.md Co-authored-by: Nathan Bower <[email protected]> Signed-off-by: Asim M <[email protected]> --------- Signed-off-by: Siddharth Rayabharam <[email protected]> Signed-off-by: Asim Mahmood <[email protected]> Signed-off-by: Fanit Kolchina <[email protected]> Signed-off-by: Asim M <[email protected]> Co-authored-by: Siddharth Rayabharam <[email protected]> Co-authored-by: Fanit Kolchina <[email protected]> Co-authored-by: kolchfa-aws <[email protected]> Co-authored-by: Nathan Bower <[email protected]> Signed-off-by: Eric Pugh <[email protected]>
1 parent 0deb928 commit 01c495b

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)