Bird
0
0

Which of the following is the correct syntax to add a must_not clause inside a bool query in Elasticsearch?

easy📝 Syntax Q3 of 15
Elasticsearch - Basic Search Queries
Which of the following is the correct syntax to add a must_not clause inside a bool query in Elasticsearch?
A"must_not": [{ "term": { "status": "inactive" } }]
B"must": [{ "term": { "status": "inactive" } }]
C"should": [{ "term": { "status": "inactive" } }]
D"filter": [{ "term": { "status": "inactive" } }]
Step-by-Step Solution
Solution:
  1. Step 1: Identify the clause to exclude documents

    The must_not clause excludes documents matching the condition.
  2. Step 2: Check syntax correctness

    The syntax for must_not is an array of conditions, e.g., "must_not": [{ "term": { "field": "value" } }].
  3. Final Answer:

    "must_not": [{ "term": { "status": "inactive" } }] -> Option A
  4. Quick Check:

    Exclude condition syntax = must_not [OK]
Quick Trick: Use must_not with array of conditions to exclude matches [OK]
Common Mistakes:
MISTAKES
  • Using must instead of must_not
  • Incorrect array brackets

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes