Bird
Raised Fist0

Which of the following is the correct JSON structure to apply a filter in a saved search?

easy📝 Syntax Q12 of Q15
Elasticsearch - Kibana and Visualization
Which of the following is the correct JSON structure to apply a filter in a saved search?
A{"query": {"match_all": {}}, "filter": {"term": {"status": "active"}}}
B{"query": {"filtered": {"filter": {"term": {"status": "active"}}}}}
C{"query": {"term": {"status": "active"}}}
D{"filter": {"match": {"status": "active"}}}
Step-by-Step Solution
Solution:
  1. Step 1: Recall filter syntax in Elasticsearch saved searches

    Filters are applied inside a filtered query using the "filtered" key.
  2. Step 2: Check each option's structure

    {"query": {"filtered": {"filter": {"term": {"status": "active"}}}}} correctly uses "query": {"filtered": {"filter": {...}}} which is the right way to apply filters.
  3. Final Answer:

    {"query": {"filtered": {"filter": {"term": {"status": "active"}}}}} -> Option B
  4. Quick Check:

    Filter inside filtered query = {"query": {"filtered": {"filter": {"term": {"status": "active"}}}}} [OK]
Quick Trick: Filters go inside a filtered query block in JSON [OK]
Common Mistakes:
MISTAKES
  • Putting filter outside query block
  • Using match instead of term for exact filter
  • Missing filtered wrapper for filters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes