0
0
Elasticsearchquery~10 mins

Dashboard creation 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 create a basic search query in Elasticsearch.

Elasticsearch
{
  "query": {
    "match": {
      "message": "[1]"
    }
  }
}
Drag options to blanks, or click blank then click option'
Auser
Bstatus
Cerror
Dtimestamp
Attempts:
3 left
💡 Hint
Common Mistakes
Using a field name instead of a search term inside the match query.
Leaving the search term blank.
2fill in blank
medium

Complete the code to filter documents where the status is 'active'.

Elasticsearch
{
  "query": {
    "bool": {
      "filter": {
        "term": { "status": "[1]" }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aactive
Binactive
Cpending
Ddeleted
Attempts:
3 left
💡 Hint
Common Mistakes
Using a value that does not exist in the data.
Confusing filter with query for partial matches.
3fill in blank
hard

Fix the error in the aggregation to count documents by user.

Elasticsearch
{
  "aggs": {
    "users_count": {
      "terms": { "field": "[1]" }
    }
  }
}
Drag options to blanks, or click blank then click option'
Auser
Buser.keyword
Cusers
Dusername
Attempts:
3 left
💡 Hint
Common Mistakes
Using the analyzed text field which causes aggregation errors.
Using a field name that does not exist.
4fill in blank
hard

Fill both blanks to create a date histogram aggregation for monthly data.

Elasticsearch
{
  "aggs": {
    "sales_over_time": {
      "date_histogram": {
        "field": "[1]",
        "interval": "[2]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Asale_date
Bmonth
Cday
Dtimestamp
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-date field for the histogram.
Setting an invalid interval value.
5fill in blank
hard

Fill all three blanks to create a filtered aggregation counting errors in the last 7 days.

Elasticsearch
{
  "query": {
    "bool": {
      "filter": [
        { "term": { "level": "[1]" } },
        { "range": { "timestamp": { "gte": "now-[2]d/d" } } }
      ]
    }
  },
  "aggs": {
    "error_count": {
      "value_count": { "field": "[3]" }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aerror
B7
Cmessage
Dwarning
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong level value like 'warning'.
Setting the wrong date range.
Counting a field that does not exist.