0
0
Elasticsearchquery~20 mins

Match query in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Match Query Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Match query?
Given the following Elasticsearch Match query, what documents will be matched if the index contains documents with the field title having values:
1. "Quick brown fox"
2. "Brown fox jumps"
3. "Lazy dog"

Query:
{"query": {"match": {"title": "brown fox"}}}
Elasticsearch
{"query": {"match": {"title": "brown fox"}}}
ADocuments 1 and 2 only
BDocuments 1, 2, and 3
CDocument 2 only
DDocument 3 only
Attempts:
2 left
💡 Hint
Match query analyzes the input text and looks for documents containing any of the terms after analysis.
🧠 Conceptual
intermediate
1:30remaining
How does the operator parameter affect a Match query?
In an Elasticsearch Match query, what is the effect of setting the operator parameter to and instead of the default or?
AThe query matches documents containing none of the terms
BThe query matches documents containing all the terms in the query string
CThe query matches documents containing any of the terms in the query string
DThe query matches documents only if the terms appear in the exact order
Attempts:
2 left
💡 Hint
Think about how 'and' changes the condition from 'any' to 'all'.
🔧 Debug
advanced
2:30remaining
Why does this Match query return no results?
Consider this Match query:
{"query": {"match": {"description": {"query": "fast runner", "operator": "and"}}}}

Given documents:
1. {"description": "fast and agile"}
2. {"description": "runner and jumper"}
3. {"description": "fast runner"}

Why does the query return only document 3?
ABecause the query string is treated as a phrase and only exact matches are returned
BBecause the query is missing a 'match_phrase' type
CBecause operator 'and' requires both 'fast' and 'runner' to be present in the same document
DBecause the field 'description' is not analyzed
Attempts:
2 left
💡 Hint
Check how the 'and' operator affects term matching in documents.
📝 Syntax
advanced
1:30remaining
Identify the syntax error in this Match query
Which option contains a syntax error in the Elasticsearch Match query?
A{"query": {"match": {"content": {"query": "quick fox", "operator": "or"}}}}
B{"query": {"match": {"content": {"query": "quick fox", "fuzziness": "AUTO"}}}}
C{"query": {"match": {"content": "quick fox"}}}
D{"query": {"match": {"content": {"query": "quick fox", "operator": or}}}}
Attempts:
2 left
💡 Hint
Check the quotes around string values in JSON.
🚀 Application
expert
3:00remaining
Which Match query option produces exactly 2 matched documents?
Given an index with documents:
1. {"text": "apple banana cherry"}
2. {"text": "banana cherry"}
3. {"text": "apple cherry"}
4. {"text": "banana apple"}

Which Match query will match exactly documents 1 and 3?
A{"query": {"match": {"text": {"query": "apple cherry", "operator": "and"}}}}
B{"query": {"match": {"text": {"query": "banana cherry", "operator": "and"}}}}
C{"query": {"match": {"text": {"query": "apple banana", "operator": "or"}}}}
D{"query": {"match": {"text": {"query": "apple", "operator": "and"}}}}
Attempts:
2 left
💡 Hint
Look for documents containing both 'apple' and 'cherry'.