# Smart price aggregation

**URL:** <https://discuss.elastic.co/t/smart-price-aggregation/73925>\
**Category:** Elasticsearch\
**Created:** [February 4, 2017, 2:11am UTC](https://discuss.elastic.co/t/smart-price-aggregation/73925 "2017-02-04T02:11:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![diego.bernardes](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@diego.bernardes](https://discuss.elastic.co/u/diego.bernardes)\
**Post date:** [February 4, 2017, 2:11am UTC](https://discuss.elastic.co/t/smart-price-aggregation/73925/1 "2017-02-04T02:11:17Z")

</div>

I'm working into a new search for a ecommerce and need to do a better aggregation on the price field.  
The current filter is just awful, we do a stats aggregation to know the lowest and bigger price, then we manually create 5 ranges of price and it's made another query with a range aggregation to finally get the count of products in the 5 ranges of price.

But this is very complex and slow, i know, there must be a way to do this simples and better.  
Elasticsearch provide something to do this automatic?  
And if yes, there is any way to do a better distribution? Today we just equally create the 5 slots, but most of times, the products stay into a same price range, so in this range is where most of the slots should stay.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 4, 2017, 2:12am UTC](https://discuss.elastic.co/t/smart-price-aggregation/73925/2 "2017-03-04T02:12:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
