# Dynamic buckets ranges?

**URL:** <https://discuss.elastic.co/t/dynamic-buckets-ranges/328584>\
**Category:** Elasticsearch\
**Created:** [March 27, 2023, 8:02am UTC](https://discuss.elastic.co/t/dynamic-buckets-ranges/328584 "2023-03-27T08:02:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![henrilabarre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henrilabarre/32/16909_2.png) [@henrilabarre](https://discuss.elastic.co/u/henrilabarre)\
**Post date:** [March 27, 2023, 8:02am UTC](https://discuss.elastic.co/t/dynamic-buckets-ranges/328584/1 "2023-03-27T08:02:31Z")

</div>

Hi all

I have a list a properties with zip code, square meter, number of rooms, sale price... in ES and with an input I want to build a query to get the optimal price range for a new property which depend of course of all the criteria. My aim is to get a minimal result (count) and the lower avg price based on equivalents in database.

I want to get if possible the optimal buckets range of criteria to get this avg lower price.

I don't want to make multi queries in order to get this price. Do you know if it's possible to build a query with new property as input and get in result the optimal buckets range as result?

For example the new property may be like that:

square meter : 150  
number of rooms : 7  
square meter of the land: 200  
zip code: 59000  
type: house

I want to query the database for all houses located at less 600 meter of the new property and make an analyse of the result in order to get the criteria to get the lower price possible. For example:

square meter between : 100 and 200  
number of room between: 5 and 8  
...

Thanks for your help on this

---

<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:** [April 24, 2023, 8:02am UTC](https://discuss.elastic.co/t/dynamic-buckets-ranges/328584/2 "2023-04-24T08:02:45Z")

</div>

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