0
0
Elasticsearchquery~10 mins

Search performance tuning 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 limit the number of search results returned to 10.

Elasticsearch
{
  "query": { "match_all": {} },
  "size": [1]
}
Drag options to blanks, or click blank then click option'
A100
B10
C0
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or negative numbers disables results or causes errors.
2fill in blank
medium

Complete the code to use a term query for exact match on the field status with value active.

Elasticsearch
{
  "query": {
    "[1]": {
      "status": "active"
    }
  }
}
Drag options to blanks, or click blank then click option'
Amatch
Brange
Cterm
Dexists
Attempts:
3 left
💡 Hint
Common Mistakes
Using match causes full-text search, which is slower and less precise.
3fill in blank
hard

Fix the error in the aggregation to calculate average price.

Elasticsearch
{
  "aggs": {
    "avg_price": {
      "avg": {
        "field": "[1]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aprice.raw
Bprice.keyword
Cprice.text
Dprice
Attempts:
3 left
💡 Hint
Common Mistakes
Using price.keyword or text fields causes aggregation errors.
4fill in blank
hard

Fill both blanks to filter documents where age is greater than 30 and sort by join_date descending.

Elasticsearch
{
  "query": {
    "range": {
      "age": {
        "[1]": 30
      }
    }
  },
  "sort": [
    { "join_date": { "order": "[2]" } }
  ]
}
Drag options to blanks, or click blank then click option'
Agt
Bgte
Cdesc
Dasc
Attempts:
3 left
💡 Hint
Common Mistakes
Using gte includes 30, which is not requested.
Using asc sorts oldest first.
5fill in blank
hard

Fill all three blanks to create a filtered aggregation that counts documents with status 'active' and average score above 50.

Elasticsearch
{
  "query": {
    "term": { "status": "[1]" }
  },
  "aggs": {
    "high_score": {
      "filter": {
        "range": {
          "score": { "[2]": [3] }
        }
      },
      "aggs": {
        "avg_score": { "avg": { "field": "score" } }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aactive
Bgt
C50
Dgte
Attempts:
3 left
💡 Hint
Common Mistakes
Using gte includes 50, which is not requested.
Using wrong status value causes no results.