orders with sample order documentscardinality aggregation query using the field variableorders with sample order documentscardinality aggregation query using the field variableorders index with sample dataorders with these exact documents: {"order_id": 1, "customer_id": "C1"}, {"order_id": 2, "customer_id": "C2"}, {"order_id": 3, "customer_id": "C1"}, {"order_id": 4, "customer_id": "C3"}.Use PUT /orders/_doc/{id} to add each document with the exact fields and values.
field_name and set it to the string "customer_id".Just assign the string "customer_id" to the variable field_name.
cardinality aggregation on the field stored in field_name. Use the aggregation name unique_customers.Use "aggs": { "unique_customers": { "cardinality": { "field": field_name }}} inside the query.
print(result['aggregations']['unique_customers']['value']).Use the print statement to show the value inside result['aggregations']['unique_customers']['value'].
What does the cardinality aggregation in Elasticsearch do?
Which of the following is the correct syntax to define a cardinality aggregation on the field user_id in Elasticsearch?
{
"aggs": {
"unique_users": {
"cardinality": {
"field": "user_id"
}
}
}
}Given the following Elasticsearch aggregation query:
{
"aggs": {
"unique_countries": {
"cardinality": {
"field": "country"
}
}
}
}If the indexed documents have countries: ["US", "US", "FR", "DE", "FR", "JP"], what is the expected approximate output value for unique_countries?
Identify the error in this cardinality aggregation query:
{
"aggs": {
"unique_users": {
"cardinality": {
"field_name": "user_id"
}
}
}
}You want to find the approximate number of unique products sold in each category using Elasticsearch. Which aggregation setup correctly combines terms and cardinality aggregations?
{
"aggs": {
"by_category": {
"terms": { "field": "category" },
"aggs": {
"unique_products": {
"cardinality": { "field": "product_id" }
}
}
}
}
}Pass the test and this pattern moves unknown