Recall & Review
beginner
What is a constant score query in Elasticsearch?
A constant score query wraps another query and returns a fixed score for all matching documents, ignoring the relevance score of the wrapped query.
Click to reveal answer
beginner
Why would you use a constant score query instead of a regular query?
To improve performance when you only need to filter documents without scoring them differently, or when you want all matching documents to have the same score.
Click to reveal answer
beginner
How do you specify a constant score query in Elasticsearch JSON DSL?
You use the
constant_score object with a filter or query inside it, like this:<br>{"constant_score": {"filter": { ... }}}Click to reveal answer
beginner
What happens to the score of documents matched by a constant score query?
All matched documents receive the same fixed score, which is 1 by default, regardless of how well they match the inner query.
Click to reveal answer
intermediate
Can you combine a constant score query with other queries in Elasticsearch?
Yes, you can combine it inside a
bool query or other compound queries to control scoring behavior for parts of your search.Click to reveal answer
What does a constant score query do in Elasticsearch?
✗ Incorrect
A constant score query returns a fixed score for all documents that match the inner query or filter.
Which key is used inside a constant score query to specify the condition?
✗ Incorrect
The
filter key is used inside a constant score query to specify the condition that documents must meet.What is the default score assigned by a constant score query to matching documents?
✗ Incorrect
By default, all matching documents get a score of 1 in a constant score query.
Why might you choose a constant score query over a regular query?
✗ Incorrect
Constant score queries improve performance by avoiding complex scoring calculations.
Can a constant score query be used inside a bool query?
✗ Incorrect
Constant score queries can be combined inside bool queries to control scoring behavior.
Explain what a constant score query is and when you would use it.
Think about scoring and filtering in search results.
You got /3 concepts.
Describe how to write a constant score query in Elasticsearch JSON DSL.
Focus on the JSON keys and nesting.
You got /3 concepts.