Complete the code to start a function score query with the correct key.
{
"[1]": {
"query": {
"match_all": {}
}
}
}The top-level key for a function score query is function_score.
Complete the code to add a weight function inside the function score query.
{
"function_score": {
"query": { "match_all": {} },
"functions": [
{
"[1]": 5
}
]
}
}The weight function assigns a fixed weight to matching documents.
Fix the error in the function score query by completing the missing key for the filter.
{
"function_score": {
"query": { "match_all": {} },
"functions": [
{
"filter": { "term": { "status": "active" } },
"weight": 3
}
],
"[1]": "sum"
}
}The score_mode defines how scores from functions are combined, e.g., 'sum'.
Fill both blanks to create a function score query that uses a field value factor and multiplies the score.
{
"function_score": {
"query": { "match": { "title": "[1]" } },
"functions": [
{
"field_value_factor": {
"field": "popularity"
}
}
],
"[2]": "multiply"
}
}The query matches the term 'elasticsearch' in the title, and score_mode is set to 'multiply' to multiply scores.
Fill all three blanks to build a function score query with a script score, a filter, and a boost mode.
{
"function_score": {
"query": { "match_all": {} },
"functions": [
{
"[1]": {
"script": {
"source": "doc['views'].value / 10"
}
},
"filter": { "term": { "category": "[2]" } }
}
],
"[3]": "replace"
}
}The function uses a script_score to calculate score, filters by category 'technology', and sets boost_mode to 'replace' to use function score only.