Challenge - 5 Problems
Boosting Query Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this boosting query?
Given the following Elasticsearch boosting query, what documents will be boosted and how?
Elasticsearch
{
"query": {
"boosting": {
"positive": {
"match": {"title": "apple"}
},
"negative": {
"match": {"title": "banana"}
},
"negative_boost": 0.2
}
}
}Attempts:
2 left
💡 Hint
Remember that the positive query boosts scores, and the negative query reduces scores by the negative_boost factor.
✗ Incorrect
The boosting query increases the score of documents matching the positive query ("apple") and reduces the score of documents matching the negative query ("banana") by multiplying their score by 0.2 (reducing by 80%).
🧠 Conceptual
intermediate1:30remaining
Which statement best describes the purpose of the negative_boost parameter?
In an Elasticsearch boosting query, what does the negative_boost parameter do?
Attempts:
2 left
💡 Hint
Think about how the negative query affects scoring.
✗ Incorrect
The negative_boost parameter multiplies the score of documents matching the negative query by a factor less than 1, effectively lowering their relevance.
🔧 Debug
advanced2:00remaining
Why does this boosting query cause a syntax error?
Identify the error in this boosting query and its cause:
{
"query": {
"boosting": {
"positive": {
"match": {"content": "python"}
},
"negative": {
"match": {"content": "java"}
},
"negative_boost": "0.5"
}
}
}
Attempts:
2 left
💡 Hint
Check the data type of negative_boost.
✗ Incorrect
The negative_boost parameter must be a numeric value, not a string. Using quotes causes a syntax error.
❓ Predict Output
advanced2:00remaining
What is the effect of this boosting query on document scores?
Consider this boosting query:
{
"query": {
"boosting": {
"positive": {
"term": {"category": "electronics"}
},
"negative": {
"term": {"brand": "generic"}
},
"negative_boost": 0.1
}
}
}
What happens to documents in the "electronics" category with brand "generic"?
Attempts:
2 left
💡 Hint
Both positive and negative queries can match the same document.
✗ Incorrect
Documents matching both positive and negative queries get their score boosted by the positive query but then multiplied by negative_boost (0.1), resulting in a significant reduction.
🚀 Application
expert2:30remaining
How many documents will have their scores reduced by this boosting query?
Given an index with 1000 documents, 300 contain "python" in the "tags" field, 150 contain "beginner" in the "tags" field, and 50 contain both.
Using this boosting query:
{
"query": {
"boosting": {
"positive": {
"match": {"tags": "python"}
},
"negative": {
"match": {"tags": "beginner"}
},
"negative_boost": 0.3
}
}
}
How many documents will have their scores reduced by the negative_boost?
Attempts:
2 left
💡 Hint
Only documents matching the negative query have their scores reduced.
✗ Incorrect
The negative query matches 150 documents with "beginner" tag, so those 150 documents have their scores multiplied by 0.3, reducing their scores.