0
0
Elasticsearchquery~10 mins

TF-IDF and BM25 scoring in Elasticsearch - Interactive Code Practice

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

Complete the code to set the similarity to BM25 in the Elasticsearch index settings.

Elasticsearch
{
  "settings": {
    "similarity": {
      "default": {
        "type": "[1]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Abm25
Btfidf
Cclassic
Dboolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using "tfidf" which is not a valid similarity type in Elasticsearch.
Using "classic" which refers to TF-IDF but is deprecated.
Using "boolean" which is a different similarity model.
2fill in blank
medium

Complete the query to use the classic TF-IDF similarity for a specific field.

Elasticsearch
{
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "similarity": "[1]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Abm25
Btfidf
Cboolean
Dclassic
Attempts:
3 left
💡 Hint
Common Mistakes
Using "tfidf" which is not a valid similarity type in Elasticsearch.
Using "bm25" which is the default but not TF-IDF.
Using "boolean" which is a different similarity model.
3fill in blank
hard

Fix the error in the BM25 parameter setting to adjust the k1 parameter.

Elasticsearch
{
  "settings": {
    "similarity": {
      "my_bm25": {
        "type": "bm25",
        "k1": [1]
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
A1.2
Btrue
Ck1
D"1.2"
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the number in quotes making it a string.
Using the parameter name as the value.
Using boolean values instead of numbers.
4fill in blank
hard

Fill both blanks to create a custom similarity with BM25 and set the b parameter.

Elasticsearch
{
  "settings": {
    "similarity": {
      "custom_bm25": {
        "type": "[1]",
        "b": [2]
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Abm25
Bclassic
C0.75
D1.5
Attempts:
3 left
💡 Hint
Common Mistakes
Using "classic" instead of "bm25" for the similarity type.
Setting b to a value greater than 1 or as a string.
Confusing b with k1 parameter.
5fill in blank
hard

Fill all three blanks to define a custom BM25 similarity with k1 and b parameters and apply it to a field.

Elasticsearch
{
  "settings": {
    "similarity": {
      "custom_bm25": {
        "type": "[1]",
        "k1": [2],
        "b": [3]
      }
    }
  },
  "mappings": {
    "properties": {
      "description": {
        "type": "text",
        "similarity": "custom_bm25"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Abm25
B1.2
C0.75
Dclassic
Attempts:
3 left
💡 Hint
Common Mistakes
Using "classic" instead of "bm25" for the type.
Putting numeric parameters in quotes.
Omitting the similarity setting in the field mapping.