A. Documents where the title field contains the exact phrase "quick brown fox".
B. Documents where the title field contains only the word "fox".
C. Documents where the title field is empty.
D. Documents where the title field contains any of the words "quick", "brown", or "fox".
Solution
Step 1: Understand how match query works with multiple words
The match query analyzes the text and searches for documents containing any of the words, not necessarily the exact phrase.
Step 2: Compare options with this behavior
Documents where the title field contains any of the words "quick", "brown", or "fox". correctly states it searches for any of the words. Documents where the title field contains the exact phrase "quick brown fox". is phrase match, which requires a different query type.
Final Answer:
Documents where the title field contains any of the words "quick", "brown", or "fox". -> Option D
Quick Check:
match = any word match [OK]
Hint: Match finds any word in text, not exact phrase [OK]
Common Mistakes:
Thinking match does exact phrase search
Assuming match finds only one word
Confusing match with match_phrase query
4.
Identify the error in this Elasticsearch query:
{
"query": {
"match": {
"content": apple
}
}
}
medium
A. The match query should be outside the query object.
B. The field name content should be in quotes.
C. The search text apple should be in quotes.
D. The query object is missing a closing brace.
Solution
Step 1: Check JSON syntax for values
In JSON, string values must be enclosed in double quotes. Here, apple is unquoted.
Step 2: Verify other parts of the query
The field name and braces are correctly quoted and closed. The match query is correctly inside query.
Final Answer:
The search text apple should be in quotes. -> Option C
Quick Check:
Strings need quotes in JSON [OK]
Hint: Always quote string values in JSON queries [OK]
Common Mistakes:
Leaving string values unquoted
Misplacing match outside query
Forgetting closing braces
5.
You want to find documents where the field "description" contains the word "fresh" but only if the field "category" equals "fruit". Which Elasticsearch query correctly combines these conditions?