0
0
Elasticsearchquery~10 mins

Stats and extended stats 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 basic statistics on the field 'price'.

Elasticsearch
{
  "aggs": {
    "price_stats": {
      "stats": {
        "field": "[1]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Auser
Bquantity
Cdate
Dprice
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-numeric field like 'date' or 'user' causes errors.
Leaving the field name blank results in no aggregation.
2fill in blank
medium

Complete the code to calculate extended statistics on the field 'score'.

Elasticsearch
{
  "aggs": {
    "score_extended_stats": {
      "extended_stats": {
        "field": "[1]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aage
Bscore
Cname
Dtimestamp
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting a non-numeric field causes aggregation failure.
Using a field unrelated to the data context leads to meaningless results.
3fill in blank
hard

Fix the error in the aggregation by completing the missing field name.

Elasticsearch
{
  "aggs": {
    "sales_stats": {
      "stats": {
        "field": "[1]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Asales_amount
Bsales_date
Ccustomer_name
Dregion
Attempts:
3 left
💡 Hint
Common Mistakes
Using a date or string field causes aggregation errors.
Leaving the field empty results in no output.
4fill in blank
hard

Fill both blanks to calculate extended stats on 'temperature' and filter values greater than 20.

Elasticsearch
{
  "aggs": {
    "temp_stats": {
      "extended_stats": {
        "field": "[1]"
      }
    },
    "filtered_temps": {
      "filter": {
        "range": {
          "[2]": {
            "gt": 20
          }
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Atemperature
Bhumidity
Dpressure
Attempts:
3 left
💡 Hint
Common Mistakes
Using different fields for aggregation and filter causes inconsistent results.
Selecting non-numeric fields for stats or range filter causes errors.
5fill in blank
hard

Fill all three blanks to create an extended stats aggregation on 'duration', include a filter for values less than 100, and name the aggregation 'duration_stats'.

Elasticsearch
{
  "aggs": {
    "[1]": {
      "extended_stats": {
        "field": "[2]"
      }
    },
    "filtered_duration": {
      "filter": {
        "range": {
          "[3]": {
            "lt": 100
          }
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aduration_stats
Bduration
Dtime
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching aggregation name and field names causes confusion.
Using different fields for aggregation and filter leads to incorrect results.