Complete the code to specify the field to search in Elasticsearch.
{
"query": {
"match": {
"[1]": "search text"
}
}
}The match query requires the field name to search. Here, title is the correct field to search text in.
Complete the code to add a boost factor to increase relevance of the field.
{
"query": {
"match": {
"title": {
"query": "search text",
"[1]": 2
}
}
}
}The boost parameter increases the importance of the field in scoring.
Fix the error in the code to correctly use the function_score query for custom scoring.
{
"query": {
"function_score": {
"query": { "match_all": {} },
"[1]": [
{
"weight": 2
}
]
}
}
}The function_score query uses the functions array to define scoring functions.
Fill both blanks to create a query that boosts documents with a specific tag.
{
"query": {
"function_score": {
"query": { "match": { "content": "search" } },
"[1]": [
{
"filter": { "term": { "tag": "important" } },
"[2]": 3
}
]
}
}
}The functions array holds scoring functions, and weight sets the boost value.
Fill all three blanks to create a query that boosts documents with tag 'vip' and sorts by score descending.
{
"query": {
"function_score": {
"query": { "match_all": {} },
"[1]": [
{
"filter": { "term": { "tag": "vip" } },
"[2]": 5
}
]
}
},
"sort": [
{ "[3]": { "order": "desc" } }
]
}The functions array holds scoring functions, weight sets boost, and sorting by _score orders results by relevance.