0
0
Elasticsearchquery~5 mins

Filter aggregation in Elasticsearch - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a filter aggregation in Elasticsearch?
A filter aggregation lets you count or analyze documents that match a specific filter condition, like counting only documents with a certain field value.
Click to reveal answer
beginner
How do you define a filter aggregation in an Elasticsearch query?
You define it by specifying a filter with a query inside the aggregation, like "filter": { "term": { "status": "active" } }.
Click to reveal answer
intermediate
Can filter aggregation be combined with other aggregations?
Yes! You can nest other aggregations inside a filter aggregation to analyze only the filtered documents further.
Click to reveal answer
intermediate
What is the difference between filter aggregation and filters aggregation?
Filter aggregation uses one filter to select documents. Filters aggregation lets you define multiple filters and get results for each filter separately.
Click to reveal answer
beginner
Example: What does this filter aggregation do?
{
  "aggs": {
    "active_users": {
      "filter": { "term": { "status": "active" } }
    }
  }
}
It counts how many documents have the field status set to active. The result is the number of active users.
Click to reveal answer
What does a filter aggregation do in Elasticsearch?
ADeletes documents matching a filter
BCounts documents matching a filter
CUpdates documents matching a filter
DSorts documents by a field
Which key is used to specify the filter in a filter aggregation?
A"filter"
B"query"
C"match"
D"term"
Can you nest other aggregations inside a filter aggregation?
AYes
BNo
COnly in filters aggregation
DOnly with terms aggregation
What is the main difference between filter and filters aggregations?
AFilter is faster than filters
BFilter sorts documents; filters counts documents
CFilter updates documents; filters deletes documents
DFilter uses one filter; filters uses multiple filters
In this filter aggregation, what does it count?
{
  "filter": { "term": { "status": "active" } }
}
AAll documents
BDocuments with status inactive
CDocuments with status active
DDocuments without status field
Explain how filter aggregation works in Elasticsearch and give a simple example.
Think about how you count only certain documents using a filter.
You got /3 concepts.
    Describe the difference between filter aggregation and filters aggregation.
    One uses one filter, the other uses many filters at once.
    You got /3 concepts.