A function score query lets you modify the score of documents returned by a query using functions like boosting, decay, or script scoring. It helps customize how results are ranked.
Click to reveal answer
beginner
Name two common functions used inside a function score query.
Common functions include weight (to boost scores by a fixed number) and decay functions like gauss or exp that reduce scores based on distance from a point.
Click to reveal answer
intermediate
What does the boost_mode parameter do in a function score query?
boost_mode controls how the original query score and the function score combine. Options include multiply, sum, replace, and more.
Click to reveal answer
intermediate
Explain the purpose of the score_mode in a function score query.
score_mode defines how multiple functions' scores combine when more than one function applies. For example, sum adds them, multiply multiplies them, and max picks the highest.
Click to reveal answer
beginner
Show a simple example of a function score query that boosts documents with a field is_featured set to true.
The "functions" field must be an array of function objects, not a single object.
Step 2: Identify the error in the query
Here, "functions" is incorrectly given as an object with "weight" key instead of an array containing that object.
Final Answer:
"functions" should be an array, not an object -> Option D
Quick Check:
Functions must be array = "functions" should be an array, not an object [OK]
Hint: Functions must be an array of objects [OK]
Common Mistakes:
Using object instead of array for functions
Placing query inside functions
Assuming score_mode is mandatory
5. You want to boost documents with a popularity field greater than 10 by a factor of 5 using a function_score query. Which snippet correctly applies this boost?