0
0
Elasticsearchquery~10 mins

Discover for data exploration 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 search all documents in the index.

Elasticsearch
GET /my-index/_search
{
  "[1]": {
    "match_all": {}
  }
}
Drag options to blanks, or click blank then click option'
Asort
Bfilter
Cquery
Daggs
Attempts:
3 left
💡 Hint
Common Mistakes
Using filter instead of query causes no results.
Using sort or aggs in place of query causes errors.
2fill in blank
medium

Complete the code to return only the first 5 documents.

Elasticsearch
GET /my-index/_search
{
  "size": [1],
  "query": { "match_all": {} }
}
Drag options to blanks, or click blank then click option'
A10
B5
C0
D50
Attempts:
3 left
💡 Hint
Common Mistakes
Setting size to 0 returns no documents.
Using a large number like 50 returns more than needed.
3fill in blank
hard

Fix the error in the query to filter documents where the field 'status' is 'active'.

Elasticsearch
GET /my-index/_search
{
  "query": {
    "term": { "[1]": "active" }
  }
}
Drag options to blanks, or click blank then click option'
Astatus
Bterm
Cactive
Dstate
Attempts:
3 left
💡 Hint
Common Mistakes
Using the value 'active' as the key causes errors.
Using a wrong field name like 'state' returns no results.
4fill in blank
hard

Fill both blanks to sort documents by 'timestamp' in descending order.

Elasticsearch
GET /my-index/_search
{
  "sort": [
    { "[1]": { "order": "[2]" } }
  ]
}
Drag options to blanks, or click blank then click option'
Atimestamp
Bdesc
Casc
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using date instead of timestamp if the field is named differently.
Using asc instead of desc to get newest first.
5fill in blank
hard

Fill all three blanks to aggregate the average 'price' of products where 'category' is 'books'.

Elasticsearch
GET /my-index/_search
{
  "query": {
    "term": { "[1]": "books" }
  },
  "aggs": {
    "average_price": { "avg": { "field": "[2]" } }
  },
  "size": [3]
}
Drag options to blanks, or click blank then click option'
Acategory
Bprice
C0
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Setting size to a positive number shows documents instead of only aggregation.
Using wrong field names for filtering or aggregation.