Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The constant score query requires a filter clause. Using a term filter like {"term": {"status": "active"}} is correct.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'score' or 'value' instead of 'boost'.
Placing the boost parameter outside the constant_score object.
✗ Incorrect
The boost parameter sets the constant score value in a constant_score query.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'query' instead of 'filter' inside constant_score.
Omitting the quotes around the key.
✗ Incorrect
The constant_score query requires a 'filter' key to wrap the filter query.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'query' instead of 'filter'.
Using 'score' instead of 'boost'.
✗ Incorrect
The filter key holds the range filter, and boost sets the constant score value.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'query' instead of 'constant_score' or 'filter'.
Misplacing the boost parameter.
✗ Incorrect
The outer key is 'constant_score', inside it 'filter' holds the term filter, and 'boost' sets the score.