0
0
Elasticsearchquery~20 mins

Search performance tuning in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Search Performance Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Elasticsearch query?
Given the following Elasticsearch query, what will be the total number of hits returned?
Elasticsearch
{
  "query": {
    "bool": {
      "must": [
        { "match": { "title": "python" } },
        { "range": { "publish_year": { "gte": 2015 } } }
      ]
    }
  },
  "size": 5
}
AReturns 5 documents but ignores the 'range' filter
BReturns all documents matching 'python' in title regardless of publish_year
CReturns 0 documents because 'range' filter is invalid
DReturns the top 5 documents matching 'python' in title published from 2015 onwards
Attempts:
2 left
💡 Hint
Check how the bool query combines must clauses and the size parameter limits results.
🧠 Conceptual
intermediate
2:00remaining
Which setting improves search speed by reducing scoring calculations?
In Elasticsearch, which setting can you use to improve search performance by skipping scoring calculations when relevance is not important?
A"track_total_hits": false
B"track_scores": false
C"terminate_after": 10
D"explain": true
Attempts:
2 left
💡 Hint
Think about early termination when you only need a small number of matching documents, not full relevance ranking.
🔧 Debug
advanced
3:00remaining
Why does this Elasticsearch query cause slow performance?
Consider this query: { "query": { "wildcard": { "username": "*admin*" } } } Why might this query be slow on large datasets?
AWildcard queries with leading * cause full index scans, slowing performance
BThe field 'username' is not indexed, causing errors
CThe wildcard pattern is too short and matches too few documents
DThe query syntax is invalid and causes errors
Attempts:
2 left
💡 Hint
Leading wildcards are known to be expensive in search engines.
📝 Syntax
advanced
2:30remaining
Which option correctly limits search results to documents with a specific field value and sorts by date descending?
Choose the correct Elasticsearch query syntax to filter documents where "status" is "active" and sort results by "created_date" descending.
A
{
  "query": { "term": { "status": "active" } },
  "sort": [{ "created_date": { "order": "desc" } }]
}
B
{
  "query": { "match": { "status": "active" } },
  "sort": { "created_date": "desc" }
}
C
{
  "filter": { "term": { "status": "active" } },
  "sort": [{ "created_date": "desc" }]
}
D
{
  "query": { "term": { "status": "active" } },
  "sort": [{ "created_date": { "order": "asc" } }]
}
Attempts:
2 left
💡 Hint
Check the correct use of term query and sort syntax with order key.
🚀 Application
expert
4:00remaining
How to optimize a search for a large dataset with frequent updates?
You have an Elasticsearch index with millions of documents that update frequently. You want to optimize search performance while keeping data fresh. Which approach is best?
AIncrease the number of shards to 100 to distribute load evenly
BDisable refresh interval completely to speed up indexing and search
CUse index aliases with write and read indices, and refresh the write index frequently while searching the read index
DUse wildcard queries with leading * to match updated documents quickly
Attempts:
2 left
💡 Hint
Think about separating indexing and searching to improve performance and freshness.