Recall & Review
beginner
What is a function score query in Elasticsearch?
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.Example:
{
"query": {
"function_score": {
"query": { "match_all": {} },
"functions": [
{
"filter": { "term": { "is_featured": true } },
"weight": 5
}
],
"boost_mode": "multiply"
}
}
}Click to reveal answer
What does a function score query primarily do in Elasticsearch?
✗ Incorrect
A function score query changes how documents are scored and ranked by applying functions to the original query scores.
Which parameter controls how the original score and function score combine?
✗ Incorrect
boost_mode defines how the original query score and function score combine.If you want to add scores from multiple functions, which
score_mode should you use?✗ Incorrect
sum adds the scores from multiple functions together.Which function would you use to boost documents with a specific field value?
✗ Incorrect
weight applies a fixed boost to documents matching a filter.What is the effect of setting
boost_mode to replace?✗ Incorrect
With
replace, the function score completely replaces the original query score.Describe what a function score query is and why you might use it.
Think about how you can change the importance of search results.
You got /4 concepts.
Explain the difference between
boost_mode and score_mode in a function score query.One controls original vs function, the other controls multiple functions.
You got /3 concepts.