Filter aggregation
📖 Scenario: You have a collection of products in an online store. Each product has a category and a price. You want to find out how many products are in the electronics category and cost less than 500.
🎯 Goal: Create an Elasticsearch query using filter aggregation to count products that belong to the electronics category and have a price less than 500.
📋 What You'll Learn
Create a
filter aggregation named electronics_under_500Use a
bool query with must conditions for category equals electronics and price less than 500Include a
match_all query at the top levelPrint the full JSON query as the final output
💡 Why This Matters
🌍 Real World
Filter aggregations help online stores analyze product counts based on multiple conditions, like category and price, to make business decisions.
💼 Career
Understanding filter aggregations is important for roles involving Elasticsearch, data analysis, and search engine optimization.
Progress0 / 4 steps