0
0
Elasticsearchquery~20 mins

Boosting query in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Boosting 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 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
    }
  }
}
ADocuments containing both "apple" and "banana" are boosted equally.
BDocuments containing "apple" in title are boosted; documents containing "banana" have their score reduced by 80%.
CDocuments containing "banana" are boosted; documents containing "apple" have their score reduced by 80%.
DDocuments containing "apple" or "banana" are excluded from results.
Attempts:
2 left
💡 Hint
Remember that the positive query boosts scores, and the negative query reduces scores by the negative_boost factor.
🧠 Conceptual
intermediate
1:30remaining
Which statement best describes the purpose of the negative_boost parameter?
In an Elasticsearch boosting query, what does the negative_boost parameter do?
AIt decreases the score of documents matching the negative query by a factor.
BIt increases the score of documents matching the negative query.
CIt excludes documents matching the negative query from the results.
DIt sets the minimum score for documents to be included.
Attempts:
2 left
💡 Hint
Think about how the negative query affects scoring.
🔧 Debug
advanced
2: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" } } }
AThe negative query is missing a closing bracket.
BThe positive query must be a term query, not match.
Cnegative_boost should be a number, not a string.
DThe boosting query requires a minimum_should_match parameter.
Attempts:
2 left
💡 Hint
Check the data type of negative_boost.
Predict Output
advanced
2: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"?
ATheir score is multiplied by 0.1, reducing it significantly.
BTheir score is boosted twice, increasing it.
CThey are excluded from the results.
DTheir score remains unchanged.
Attempts:
2 left
💡 Hint
Both positive and negative queries can match the same document.
🚀 Application
expert
2: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?
A200 documents
B350 documents
C50 documents
D150 documents
Attempts:
2 left
💡 Hint
Only documents matching the negative query have their scores reduced.