0
0
Elasticsearchquery~10 mins

Why aggregations summarize data in Elasticsearch - Test Your Understanding

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

Complete the code to create a terms aggregation on the field 'category'.

Elasticsearch
{
  "aggs": {
    "categories": {
      "terms": { "field": "[1]" }
    }
  }
}
Drag options to blanks, or click blank then click option'
Auser
Bprice
Cdate
Dcategory
Attempts:
3 left
💡 Hint
Common Mistakes
Using a numeric field like 'price' instead of a categorical field.
Misspelling the field name.
2fill in blank
medium

Complete the code to calculate the average price using an aggregation.

Elasticsearch
{
  "aggs": {
    "average_price": {
      "[1]": { "field": "price" }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aavg
Bsum
Cmax
Dmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sum' instead of 'avg' for average calculation.
Using 'max' or 'min' which find extremes, not averages.
3fill in blank
hard

Fix the error in the aggregation that tries to get the maximum value of 'rating'.

Elasticsearch
{
  "aggs": {
    "max_rating": {
      "max": { "field": "[1]" }
    }
  }
}
Drag options to blanks, or click blank then click option'
Arating
Bratings
Crate
Drank
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong field name like 'ratings' or 'rate'.
Typos in the field name.
4fill in blank
hard

Fill both blanks to create a date histogram aggregation on the 'timestamp' field with daily intervals.

Elasticsearch
{
  "aggs": {
    "daily_sales": {
      "date_histogram": {
        "field": "[1]",
        "interval": "[2]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Atimestamp
Bday
Chourly
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'date' instead of 'timestamp' for the field.
Using 'hourly' instead of 'day' when daily grouping is needed.
5fill in blank
hard

Fill all three blanks to create a nested aggregation that groups by 'category', then calculates the average 'price' for each category, only including categories with at least 5 documents.

Elasticsearch
{
  "aggs": {
    "categories": {
      "terms": {
        "field": "[1]",
        "min_doc_count": [2]
      },
      "aggs": {
        "average_price": {
          "[3]": { "field": "price" }
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Acategory
B5
Cavg
Dprice
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong field names for grouping or average calculation.
Setting 'min_doc_count' to a string instead of a number.