# Dynamic range facet

**URL:** <https://discuss.elastic.co/t/dynamic-range-facet/9020>\
**Category:** Elasticsearch\
**Created:** [September 14, 2012, 6:40am UTC](https://discuss.elastic.co/t/dynamic-range-facet/9020 "2012-09-14T06:40:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rauan\_Maemirov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rauan_maemirov/32/826_2.png) [@Rauan\_Maemirov](https://discuss.elastic.co/u/Rauan_Maemirov)\
**Post date:** [September 14, 2012, 6:40am UTC](https://discuss.elastic.co/t/dynamic-range-facet/9020/1 "2012-09-14T06:40:15Z")

</div>

Hi all. Is it possible to get range facets without directly indicating  
from/to ranges?  
I have an index with products, and prices are too spread. For example some  
category of products have costs around 5000 and others around 100000 or  
150000. Thus, I don't know, which queries will give me exact ranges and  
which will give me only one range with counts, i.e. all results in range  
from 0 to 1000, and zero for others.

One way is to query statistical facet for min/max, and then make another  
query with range (slices from min to max), but i don't like it.  
Any ideas, please?

--

---

<div class="post-metadata">

**Author:** ![Kim\_Major](https://avatars.discourse-cdn.com/v4/letter/k/c67d28/32.png) [@Kim\_Major](https://discuss.elastic.co/u/Kim_Major)\
**Post date:** [September 27, 2012, 11:16pm UTC](https://discuss.elastic.co/t/dynamic-range-facet/9020/2 "2012-09-27T23:16:38Z")

</div>

I have a similar scenario, did you come up with any good solutions?

On Friday, September 14, 2012 9:40:15 AM UTC+3, Rauan Maemirov wrote:

> Hi all. Is it possible to get range facets without directly indicating  
> from/to ranges?  
> I have an index with products, and prices are too spread. For example some  
> category of products have costs around 5000 and others around 100000 or  
> 150000. Thus, I don't know, which queries will give me exact ranges and  
> which will give me only one range with counts, i.e. all results in range  
> from 0 to 1000, and zero for others.
> 
> One way is to query statistical facet for min/max, and then make another  
> query with range (slices from min to max), but i don't like it.  
> Any ideas, please?

--

---

<div class="post-metadata">

**Author:** ![BillyEm](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@BillyEm](https://discuss.elastic.co/u/BillyEm)\
**Post date:** [September 29, 2012, 12:55am UTC](https://discuss.elastic.co/t/dynamic-range-facet/9020/3 "2012-09-29T00:55:29Z")

</div>

Ruan and Kim:

Earlier this week I came across an almost identical working implementation;  
in a OS component we have not yet committed to use, but the example on the  
link below for "FilteredRange..." might be worth a perusal of the source  
code.

[http://code.google.com/p/bobo-browse/wiki/CompositeFacetHandlers](http://code.google.com/p/bobo-browse/wiki/CompositeFacetHandlers)

On Friday, September 14, 2012 2:40:15 AM UTC-4, Rauan Maemirov wrote:

> Hi all. Is it possible to get range facets without directly indicating  
> from/to ranges?  
> I have an index with products, and prices are too spread. For example some  
> category of products have costs around 5000 and others around 100000 or  
> 150000. Thus, I don't know, which queries will give me exact ranges and  
> which will give me only one range with counts, i.e. all results in range  
> from 0 to 1000, and zero for others.
> 
> One way is to query statistical facet for min/max, and then make another  
> query with range (slices from min to max), but i don't like it.  
> Any ideas, please?

--

---

<div class="post-metadata">

**Author:** ![Rauan\_Maemirov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rauan_maemirov/32/826_2.png) [@Rauan\_Maemirov](https://discuss.elastic.co/u/Rauan_Maemirov)\
**Post date:** [October 16, 2012, 9:35am UTC](https://discuss.elastic.co/t/dynamic-range-facet/9020/4 "2012-10-16T09:35:58Z")

</div>

Hey all, any ideas? Other than hacking with source?

Here's discussion of similar  
problem: [Redirecting to Google Groups](https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/range$20facet/elasticsearch/zk6VvxHJtAY/suthx_plI9gJ)

I also don't want to make query twice.

Le samedi 29 septembre 2012 06:55:29 UTC+6, BillyEm a écrit :

> Ruan and Kim:
> 
> Earlier this week I came across an almost identical working  
> implementation; in a OS component we have not yet committed to use, but the  
> example on the link below for "FilteredRange..." might be worth a perusal  
> of the source code.
> 
> [Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/bobo-browse/wiki/CompositeFacetHandlers)
> 
> On Friday, September 14, 2012 2:40:15 AM UTC-4, Rauan Maemirov wrote:
> 
> > Hi all. Is it possible to get range facets without directly indicating  
> > from/to ranges?  
> > I have an index with products, and prices are too spread. For example  
> > some category of products have costs around 5000 and others around 100000  
> > or 150000. Thus, I don't know, which queries will give me exact ranges and  
> > which will give me only one range with counts, i.e. all results in range  
> > from 0 to 1000, and zero for others.
> > 
> > One way is to query statistical facet for min/max, and then make another  
> > query with range (slices from min to max), but i don't like it.  
> > Any ideas, please?

--

---

<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:** [July 6, 2017, 3:08am UTC](https://discuss.elastic.co/t/dynamic-range-facet/9020/5 "2017-07-06T03:08:36Z")

</div>


