0
0
Elasticsearchquery~10 mins

Cardinality aggregation in Elasticsearch - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the cardinality aggregation field.

Elasticsearch
{
  "aggs": {
    "unique_users": {
      "cardinality": {
        "field": "[1]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Auser_id
Btimestamp
Cmessage
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-unique field like 'message' or 'status' instead of 'user_id'.
2fill in blank
medium

Complete the code to set the precision threshold for the cardinality aggregation.

Elasticsearch
{
  "aggs": {
    "unique_users": {
      "cardinality": {
        "field": "user_id",
        "[1]": 1000
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ashard_size
Bprecision_threshold
Cmin_doc_count
Dmax_doc_count
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated parameters like 'max_doc_count' or 'min_doc_count'.
3fill in blank
hard

Fix the error in the aggregation type to correctly perform cardinality aggregation.

Elasticsearch
{
  "aggs": {
    "unique_users": {
      "[1]": {
        "field": "user_id"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aterms
Bavg
Cstats
Dcardinality
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'terms' aggregation which groups by terms but does not count unique values directly.
4fill in blank
hard

Fill both blanks to create a cardinality aggregation with a custom name and field.

Elasticsearch
{
  "aggs": {
    "[1]": {
      "cardinality": {
        "field": "[2]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aunique_visitors
Buser_id
Ctimestamp
Dunique_sessions
Attempts:
3 left
💡 Hint
Common Mistakes
Using a field like 'timestamp' which is not suitable for unique user counts.
5fill in blank
hard

Fill all three blanks to create a cardinality aggregation with a name, field, and precision threshold.

Elasticsearch
{
  "aggs": {
    "[1]": {
      "cardinality": {
        "field": "[2]",
        "[3]": 2000
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aunique_customers
Bcustomer_id
Cprecision_threshold
Dmax_precision
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect parameter names like 'max_precision' instead of 'precision_threshold'.