From the course: Elasticsearch Essential Training

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Basic aggregation

Basic aggregation

- [Instructor] Ever wondered how online stores shows you average product rating, top selling categories, or even a price distribution chart, that's all powered by the aggregation. The way you do the aggregation in the SQL world, similarly, you can do the aggregation in the elastic search as well. Let's just see how we can do that. For example, we want to find out the average price for all of our product. We can do that by just writing this specific query. We can say that, let's do the aggregation and I wanted to find out the average based on this price field, and I just execute this and I get the average price for all of my product. You also see that there is a one size attribute is there, which is set to be zero. If I set it to be 5 and execute this, I will see five extra documents. You can see that I got five products as well. So this size is actually returning you the document as well, which is used under this aggregation. In most of the cases, you don't need those documents. So…

Contents