If you have ever used Amazon (or any other large e-commerce site), you might remember that on the left-hand side of the search results, these sites provide a list of filters that users can easily select and navigate the search results. These filters are generated dynamically based on what results are shown and selecting one further narrows down the search results. It's just easier to show what I mean with a screenshot. On Amazon, if you perform a search, you'll see something similar to this on the left-hand side of the screen:
If you select any of the options listed here, you will further refine your search and see results relevant to only that option. They also provide the user with instant feedback, letting them know at a glance how many results they can expect to see if they select one of the available options.
We want to implement something similar in our application. Elasticsearch provides a feature called aggregations to help us do just this. Let's see what aggregations...