0
0
Elasticsearchquery~10 mins

Constant score query 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 create a constant score query with a filter.

Elasticsearch
{
  "constant_score": {
    "filter": [1]
  }
}
Drag options to blanks, or click blank then click option'
A{"match": {"status": "active"}}
B{"range": {"age": {"gte": 30}}}
C{"exists": {"field": "user"}}
D{"term": {"status": "active"}}
Attempts:
3 left
💡 Hint
Common Mistakes
Using a match query instead of a filter inside constant_score.
Forgetting to wrap the filter inside the constant_score object.
2fill in blank
medium

Complete the code to set the constant score value to 5.

Elasticsearch
{
  "constant_score": {
    "filter": {"term": {"status": "active"}},
    "[1]": 5
  }
}
Drag options to blanks, or click blank then click option'
Ascore
Bvalue
Cboost
Dweight
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'score' or 'value' instead of 'boost'.
Placing the boost parameter outside the constant_score object.
3fill in blank
hard

Fix the error in the constant score query by completing the missing key.

Elasticsearch
{
  "constant_score": {
    [1]: {"term": {"status": "active"}},
    "boost": 3
  }
}
Drag options to blanks, or click blank then click option'
A"filter"
B"query"
C"match"
D"term"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'query' instead of 'filter' inside constant_score.
Omitting the quotes around the key.
4fill in blank
hard

Fill both blanks to create a constant score query filtering by age greater than 25 and setting boost to 2.

Elasticsearch
{
  "constant_score": {
    [1]: {"range": {"age": {"gt": 25}}},
    [2]: 2
  }
}
Drag options to blanks, or click blank then click option'
A"filter"
B"boost"
C"query"
D"score"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'query' instead of 'filter'.
Using 'score' instead of 'boost'.
5fill in blank
hard

Fill all three blanks to create a constant score query with a term filter on "category" equal to "books", boost 4, and wrap it correctly.

Elasticsearch
{
  [1]: {
    [2]: {"term": {"category": "books"}},
    [3]: 4
  }
}
Drag options to blanks, or click blank then click option'
A"constant_score"
B"filter"
C"boost"
D"query"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'query' instead of 'constant_score' or 'filter'.
Misplacing the boost parameter.