Challenge - 5 Problems
Dis Max Query Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the score behavior of this dis_max query?
Given the following Elasticsearch dis_max query, what will be the _score of a document that matches both clauses equally with a tie_breaker of 0.3?
Elasticsearch
{
"query": {
"dis_max": {
"tie_breaker": 0.3,
"queries": [
{ "match": { "title": "apple" } },
{ "match": { "description": "apple" } }
]
}
}
}Attempts:
2 left
💡 Hint
Remember that dis_max uses the highest score plus a fraction of the others based on tie_breaker.
✗ Incorrect
The dis_max query returns the maximum score from its subqueries plus a fraction (tie_breaker) of the other scores. This helps boost documents matching multiple queries without simply summing all scores.
🧠 Conceptual
intermediate1:30remaining
Which use case best fits a dis_max query?
Which scenario is the best reason to use a dis_max query in Elasticsearch?
Attempts:
2 left
💡 Hint
Dis max is about picking the best match with some influence from others.
✗ Incorrect
Dis max is designed to pick the highest scoring query match and add a fraction of other matches, useful when you want to prefer the best match but still reward multiple matches.
🔧 Debug
advanced2:30remaining
Why does this dis_max query ignore the tie_breaker?
Consider this dis_max query:
{
"query": {
"dis_max": {
"tie_breaker": 0.5,
"queries": [
{ "match": { "field1": "test" } },
{ "match": { "field2": "test" } }
]
}
}
}
Why might the tie_breaker have no effect on the scoring?
Attempts:
2 left
💡 Hint
Tie breaker only affects when multiple queries match.
✗ Incorrect
The tie_breaker only adds a fraction of the scores from other matching queries. If only one query matches, the tie_breaker has no effect.
📝 Syntax
advanced2:00remaining
Identify the syntax error in this dis_max query
Which option contains a syntax error in the dis_max query?
Elasticsearch
{
"query": {
"dis_max": {
"tie_breaker": 0.2,
"queries": [
{ "match": { "field": "value1" } },
{ "match": { "field": "value2" } }
]
}
}
}Attempts:
2 left
💡 Hint
Check the key name for the list of queries inside dis_max.
✗ Incorrect
The correct key for the list of queries inside dis_max is "queries" not "query". Using "query" causes a syntax error.
🚀 Application
expert3:00remaining
How to combine dis_max with boosting for best relevance?
You want to search documents matching either 'title' or 'content' fields. You want the best match to score highest but also boost matches in 'title' by 2x. Which query achieves this?
Attempts:
2 left
💡 Hint
Boost inside the match query affects that field's score before dis_max combines them.
✗ Incorrect
Boosting the 'title' match inside the dis_max queries increases its score before dis_max picks the max plus tie breaker. This way, matches in 'title' get higher priority.