# Range facet seems a little different from what i understand

**URL:** <https://discuss.elastic.co/t/range-facet-seems-a-little-different-from-what-i-understand/10031>\
**Category:** Elasticsearch\
**Created:** [December 11, 2012, 9:20am UTC](https://discuss.elastic.co/t/range-facet-seems-a-little-different-from-what-i-understand/10031 "2012-12-11T09:20:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![asoqa](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@asoqa](https://discuss.elastic.co/u/asoqa)\
**Post date:** [December 11, 2012, 9:20am UTC](https://discuss.elastic.co/t/range-facet-seems-a-little-different-from-what-i-understand/10031/1 "2012-12-11T09:20:41Z")

</div>

for example:  
{  
"query" : {  
"match\_all" : {}  
},  
"facets" : {  
"range1" : {  
"range" : {  
"field" : "age",  
"ranges" : [  
{ "from" : 1, "to" : 10 }  
]  
}  
}  
}  
}  
I want to range [1, 10] on age field, but es returns results in [1, 10),  
not including the upper bound.

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [December 13, 2012, 9:11pm UTC](https://discuss.elastic.co/t/range-facet-seems-a-little-different-from-what-i-understand/10031/2 "2012-12-13T21:11:18Z")

</div>

That's how range facet actually works. It includes the lower bound  
and excludes the upper bound. If all you need is count for one range, you  
can filter facet with a range filter, that has more  
flexibility. Alternatively, if age is integer or long field, you can use  
something like 10.1 as a upper boundary.

On Tuesday, December 11, 2012 4:20:41 AM UTC-5, asoqa wrote:

> for example:  
> {  
> "query" : {  
> "match\_all" : {}  
> },  
> "facets" : {  
> "range1" : {  
> "range" : {  
> "field" : "age",  
> "ranges" : [  
> { "from" : 1, "to" : 10 }  
> ]  
> }  
> }  
> }  
> }  
> I want to range [1, 10] on age field, but es returns results in [1, 10),  
> not including the upper bound.

--

---

<div class="post-metadata">

**Author:** ![asoqa](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@asoqa](https://discuss.elastic.co/u/asoqa)\
**Post date:** [December 19, 2012, 3:08am UTC](https://discuss.elastic.co/t/range-facet-seems-a-little-different-from-what-i-understand/10031/3 "2012-12-19T03:08:39Z")

</div>

thanks , i see

在 2012年12月14日星期五UTC+8上午5时11分18秒，Igor Motov写道：

> That's how range facet actually works. It includes the lower bound  
> and excludes the upper bound. If all you need is count for one range, you  
> can filter facet with a range filter, that has more  
> flexibility. Alternatively, if age is integer or long field, you can use  
> something like 10.1 as a upper boundary.
> 
> On Tuesday, December 11, 2012 4:20:41 AM UTC-5, asoqa wrote:
> 
> > for example:  
> > {  
> > "query" : {  
> > "match\_all" : {}  
> > },  
> > "facets" : {  
> > "range1" : {  
> > "range" : {  
> > "field" : "age",  
> > "ranges" : [  
> > { "from" : 1, "to" : 10 }  
> > ]  
> > }  
> > }  
> > }  
> > }  
> > I want to range [1, 10] on age field, but es returns results in [1, 10),  
> > not including the upper bound.

--

---

<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, 2:59am UTC](https://discuss.elastic.co/t/range-facet-seems-a-little-different-from-what-i-understand/10031/4 "2017-07-06T02:59:22Z")

</div>


