0
0
Elasticsearchquery~10 mins

Metric aggregations (avg, sum, min, max) 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 calculate the average of the field "price".

Elasticsearch
{
  "aggs": {
    "average_price": {
      "[1]": {
        "field": "price"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Asum
Bavg
Cmin
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sum' instead of 'avg' will calculate the total, not the average.
Using 'min' or 'max' will give the smallest or largest value, not the average.
2fill in blank
medium

Complete the code to calculate the total sum of the field "quantity".

Elasticsearch
{
  "aggs": {
    "total_quantity": {
      "[1]": {
        "field": "quantity"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Asum
Bmin
Cavg
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'avg' will calculate the average, not the total sum.
Using 'min' or 'max' will return the smallest or largest value, not the sum.
3fill in blank
hard

Fix the error in the aggregation type to find the minimum value of "age".

Elasticsearch
{
  "aggs": {
    "youngest": {
      "[1]": {
        "field": "age"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aavg
Bsum
Cmin
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'max' will give the largest value, not the minimum.
Using 'sum' or 'avg' will not find the minimum value.
4fill in blank
hard

Fill both blanks to calculate the maximum value of "score" and the average of "time".

Elasticsearch
{
  "aggs": {
    "max_score": {
      "[1]": {
        "field": "score"
      }
    },
    "avg_time": {
      "[2]": {
        "field": "time"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Amax
Bavg
Csum
Dmin
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up 'min' and 'max' for the score aggregation.
Using 'sum' instead of 'avg' for the time aggregation.
5fill in blank
hard

Fill all three blanks to calculate the sum of "sales", the minimum of "discount", and the average of "rating".

Elasticsearch
{
  "aggs": {
    "total_sales": {
      "[1]": {
        "field": "sales"
      }
    },
    "lowest_discount": {
      "[2]": {
        "field": "discount"
      }
    },
    "average_rating": {
      "[3]": {
        "field": "rating"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aavg
Bsum
Cmin
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping 'min' and 'max' for discount.
Using 'max' instead of 'sum' for sales.
Using 'sum' instead of 'avg' for rating.