Complete the code to limit the number of search results returned to 10.
{
"query": { "match_all": {} },
"size": [1]
}Setting size to 10 limits the search results to 10 documents, improving performance by reducing data returned.
Complete the code to use a term query for exact match on the field status with value active.
{
"query": {
"[1]": {
"status": "active"
}
}
}match causes full-text search, which is slower and less precise.The term query is used for exact matches, which is faster for keyword fields like status.
Fix the error in the aggregation to calculate average price.
{
"aggs": {
"avg_price": {
"avg": {
"field": "[1]"
}
}
}
}price.keyword or text fields causes aggregation errors.The avg aggregation requires a numeric field like price, not keyword or text fields.
Fill both blanks to filter documents where age is greater than 30 and sort by join_date descending.
{
"query": {
"range": {
"age": {
"[1]": 30
}
}
},
"sort": [
{ "join_date": { "order": "[2]" } }
]
}gte includes 30, which is not requested.asc sorts oldest first.Use gt for greater than 30 and desc to sort newest first.
Fill all three blanks to create a filtered aggregation that counts documents with status 'active' and average score above 50.
{
"query": {
"term": { "status": "[1]" }
},
"aggs": {
"high_score": {
"filter": {
"range": {
"score": { "[2]": [3] }
}
},
"aggs": {
"avg_score": { "avg": { "field": "score" } }
}
}
}
}gte includes 50, which is not requested.The query filters for status 'active', then the aggregation filters scores greater than 50 before averaging.