0
0
Elasticsearchquery~20 mins

Saved searches and filters in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Saved Searches 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 saved search query?

Given this Elasticsearch saved search query, what will be the total number of hits returned?

Elasticsearch
{
  "query": {
    "bool": {
      "filter": [
        { "term": { "status": "active" } },
        { "range": { "age": { "gte": 30 } } }
      ]
    }
  }
}
AReturns all documents with status 'active' and age greater or equal to 30
BReturns all documents with status 'active' or age greater or equal to 30
CReturns documents with status 'active' but ignores age filter
DReturns documents with age greater or equal to 30 but ignores status filter
Attempts:
2 left
💡 Hint

Remember that filters inside a bool query with filter act as AND conditions.

🧠 Conceptual
intermediate
1:30remaining
Which filter type is best for exact matches in saved searches?

When creating saved searches in Elasticsearch, which filter type should you use to match exact values efficiently?

Amatch filter
Bterm filter
Crange filter
Dexists filter
Attempts:
2 left
💡 Hint

Exact matches require filters that do not analyze the field.

🔧 Debug
advanced
2:30remaining
Why does this saved search filter not work as expected?

Look at this saved search filter. It should return documents where category is either 'books' or 'electronics'. Why does it return no results?

Elasticsearch
{
  "query": {
    "bool": {
      "filter": {
        "term": { "category": ["books", "electronics"] }
      }
    }
  }
}
AThe filter should be inside a must clause, not filter
BThe category field is missing in the index mapping
CThe term filter does not accept an array of values; it expects a single value
DThe query syntax is correct; the problem is with the data
Attempts:
2 left
💡 Hint

Check the expected input type for the term filter.

📝 Syntax
advanced
2:00remaining
Identify the syntax error in this saved search filter

Which option contains the correct syntax for a saved search filter that matches documents with status 'pending' and priority greater than 5?

A{ "bool": { "filter": [ { "term": { "status": "pending" } }, { "range": { "priority": { "gt": "5" } } } ] } }
B{ "bool": { "filter": [ { "term": { "status": "pending" } }, { "range": { "priority": { "gte": 5 } } } ] } }
C{ "bool": { "filter": [ { "term": { "status": "pending" } }, { "range": { "priority": { "greater_than": 5 } } } ] } }
D{ "bool": { "filter": [ { "term": { "status": "pending" } }, { "range": { "priority": { "gt": 5 } } } ] } }
Attempts:
2 left
💡 Hint

Check the correct operator name and value types in range queries.

🚀 Application
expert
3:00remaining
How many filters are applied in this saved search?

Consider this saved search query. How many filters are effectively applied to the documents?

Elasticsearch
{
  "query": {
    "bool": {
      "must": [
        { "term": { "status": "active" } },
        { "range": { "age": { "gte": 25 } } }
      ],
      "filter": [
        { "term": { "verified": true } },
        { "range": { "score": { "gt": 50 } } }
      ]
    }
  }
}
A4 filters
B3 filters
C2 filters
D5 filters
Attempts:
2 left
💡 Hint

Count all conditions inside must and filter arrays.