0
0
Elasticsearchquery~10 mins

Why relevance scoring ranks results in Elasticsearch - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the field to search in Elasticsearch.

Elasticsearch
{
  "query": {
    "match": {
      "[1]": "search text"
    }
  }
}
Drag options to blanks, or click blank then click option'
Aauthor
Bscore
Cdate
Dtitle
Attempts:
3 left
💡 Hint
Common Mistakes
Using a numeric or date field instead of a text field.
2fill in blank
medium

Complete the code to add a boost factor to increase relevance of the field.

Elasticsearch
{
  "query": {
    "match": {
      "title": {
        "query": "search text",
        "[1]": 2
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aboost
Bscore
Cweight
Dpriority
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect parameter names like 'score' or 'weight' which are not valid here.
3fill in blank
hard

Fix the error in the code to correctly use the function_score query for custom scoring.

Elasticsearch
{
  "query": {
    "function_score": {
      "query": { "match_all": {} },
      "[1]": [
        {
          "weight": 2
        }
      ]
    }
  }
}
Drag options to blanks, or click blank then click option'
Afilters
Bfunctions
Cboosts
Dscores
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'filters' or 'boosts' which are not valid keys here.
4fill in blank
hard

Fill both blanks to create a query that boosts documents with a specific tag.

Elasticsearch
{
  "query": {
    "function_score": {
      "query": { "match": { "content": "search" } },
      "[1]": [
        {
          "filter": { "term": { "tag": "important" } },
          "[2]": 3
        }
      ]
    }
  }
}
Drag options to blanks, or click blank then click option'
Afunctions
Bweight
Cboost
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'boost' instead of 'weight' inside functions.
5fill in blank
hard

Fill all three blanks to create a query that boosts documents with tag 'vip' and sorts by score descending.

Elasticsearch
{
  "query": {
    "function_score": {
      "query": { "match_all": {} },
      "[1]": [
        {
          "filter": { "term": { "tag": "vip" } },
          "[2]": 5
        }
      ]
    }
  },
  "sort": [
    { "[3]": { "order": "desc" } }
  ]
}
Drag options to blanks, or click blank then click option'
Afunctions
Bweight
C_score
Dboost
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'boost' instead of 'weight' inside functions or sorting by a wrong field.