Recall & Review
beginner
What does the must clause do in a Bool query?
The must clause requires that the query conditions inside it must be true for a document to match. Think of it as a strict rule that must be followed.
Click to reveal answer
beginner
Explain the role of the should clause in a Bool query.
The should clause means that if the conditions inside it are true, the document scores higher, but it is not mandatory unless specified. It works like a nice-to-have feature.
Click to reveal answer
beginner
What is the purpose of the must_not clause in a Bool query?
The must_not clause excludes documents that match the conditions inside it. It acts like a filter to remove unwanted results.
Click to reveal answer
intermediate
How does the filter clause differ from must in a Bool query?
The filter clause also requires conditions to be true, but it does not affect the score of documents. It is used for fast filtering without scoring.
Click to reveal answer
intermediate
Give a simple example of a Bool query using must, should, and must_not.
Example: Find documents where field1 must be 'apple', field2 should be 'red' (optional), and field3 must not be 'rotten'. This means documents must have 'apple', prefer 'red', and exclude 'rotten'.
Click to reveal answer
In a Bool query, which clause excludes documents that match its conditions?
✗ Incorrect
The must_not clause excludes documents matching its conditions.
Which Bool query clause affects scoring of documents?
✗ Incorrect
The must clause affects scoring because it requires matching conditions.
What happens if a document matches a should clause but not a must clause?
✗ Incorrect
Documents must match must clauses; should clauses boost score if must exists.
Which clause is best for fast filtering without scoring?
✗ Incorrect
Filter clause filters documents without affecting score.
If you want to exclude documents with field 'status' equal to 'inactive', which clause do you use?
✗ Incorrect
must_not excludes documents matching the condition.
Describe the four main clauses of a Bool query and their roles.
Think about which clauses require, prefer, exclude, or filter documents.
You got /5 concepts.
Explain how you would use a Bool query to find documents that must have a value, optionally have another, and exclude a third.
Use must for must-have, should for nice-to-have, must_not for no-go.
You got /3 concepts.