Given this Elasticsearch saved search query, what will be the total number of hits returned?
{
"query": {
"bool": {
"filter": [
{ "term": { "status": "active" } },
{ "range": { "age": { "gte": 30 } } }
]
}
}
}Remember that filters inside a bool query with filter act as AND conditions.
The bool query with filter applies all conditions as AND. So only documents matching both status: active and age >= 30 are returned.
When creating saved searches in Elasticsearch, which filter type should you use to match exact values efficiently?
Exact matches require filters that do not analyze the field.
The term filter matches exact values without analyzing the field, making it efficient for exact matches in saved searches.
Look at this saved search filter. It should return documents where category is either 'books' or 'electronics'. Why does it return no results?
{
"query": {
"bool": {
"filter": {
"term": { "category": ["books", "electronics"] }
}
}
}
}Check the expected input type for the term filter.
The term filter expects a single value, not an array. To filter multiple values, use terms filter instead.
Which option contains the correct syntax for a saved search filter that matches documents with status 'pending' and priority greater than 5?
Check the correct operator name and value types in range queries.
The correct operator for greater than is gt. Option D uses gt with a numeric value 5, which is correct. Option D uses gte (greater or equal), which is not what the prompt asks. Option D uses invalid operator greater_than. Option D uses a string "5" instead of a number.
Consider this saved search query. How many filters are effectively applied to the documents?
{
"query": {
"bool": {
"must": [
{ "term": { "status": "active" } },
{ "range": { "age": { "gte": 25 } } }
],
"filter": [
{ "term": { "verified": true } },
{ "range": { "score": { "gt": 50 } } }
]
}
}
}Count all conditions inside must and filter arrays.
The must array has 2 conditions and the filter array has 2 conditions, totaling 4 filters applied to the documents.