# Histogram aggregation with float interval \< 1.0 gives ArithmeticException

**URL:** <https://discuss.elastic.co/t/histogram-aggregation-with-float-interval-1-0-gives-arithmeticexception/20447>\
**Category:** Elasticsearch\
**Created:** [October 27, 2014, 12:17pm UTC](https://discuss.elastic.co/t/histogram-aggregation-with-float-interval-1-0-gives-arithmeticexception/20447 "2014-10-27T12:17:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LiquidMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/liquidmark/32/1151_2.png) [@LiquidMark](https://discuss.elastic.co/u/LiquidMark)\
**Post date:** [October 27, 2014, 12:17pm UTC](https://discuss.elastic.co/t/histogram-aggregation-with-float-interval-1-0-gives-arithmeticexception/20447/1 "2014-10-27T12:17:06Z")

</div>

Hi, the following query (note bolded line):

{  
"query": {  
"filtered": {  
"query": {  
"term": {  
"self\_and\_ancestors": "diamonds"  
}  
},  
"filter": {  
"terms": {  
"attr\_types.diamond#color": [  
"0000d"  
]  
}  
}  
}  
},  
"sort": [  
{  
"sell\_offer\_cents": {  
"order": "asc"  
}  
}  
],  
"fields": "\_source",  
"script\_fields": {  
"gap\_cents": {  
"script": "custom\_score\_item\_bid\_ask\_gap",  
"params": {  
"individual\_price\_item\_ids": [],  
"individual\_price\_item\_cents": [],  
"pb\_amount\_below\_cents": 0  
},  
"lang": "native"  
}  
},  
"aggs": {  
"all\_items": {  
"global": {},  
"aggs": {  
"gem#carats": {  
"filter": {  
"terms": {  
"attr\_types.diamond#polish": [  
"0000ex",  
"0001vg"  
]  
}  
},  
"aggs": {  
"gems#carats": {  
"histogram": {  
"field": "attr\_types.gem#carats",  
\* "interval": 0.1,\*  
"min\_doc\_count": 0  
}  
},  
"gem#carats\_stats": {  
"stats": {  
"field": "attr\_types.gem#carats"  
}  
}  
}  
}  
}  
}  
}  
}

Gives the following error:

{  
"error": "SearchPhaseExecutionException[Failed to execute phase [query],  
all shards failed; shardFailures  
{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][4]:  
QueryPhaseExecutionException[[development-liquidibles::application-items][4]:  
query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@11ce49a\>]:  
Query Failed [Failed to execute global aggregators]]; nested:  
ArithmeticException;  
}{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][3]:  
QueryPhaseExecutionException[[development-liquidibles::application-items][3]:  
query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@8c9d82\>]:  
Query Failed [Failed to execute global aggregators]]; nested:  
ArithmeticException;  
}{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][2]:  
QueryPhaseExecutionException[[development-liquidibles::application-items][2]:  
query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@73a7e5\>]:  
Query Failed [Failed to execute global aggregators]]; nested:  
ArithmeticException;  
}{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][1]:  
QueryPhaseExecutionException[[development-liquidibles::application-items][1]:  
query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@15d1b1a\>]:  
Query Failed [Failed to execute global aggregators]]; nested:  
ArithmeticException;  
}{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][0]:  
QueryPhaseExecutionException[[development-liquidibles::application-items][0]:  
query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@1b8c216\>]:  
Query Failed [Failed to execute global aggregators]]; nested:  
_ArithmeticException_; }]",  
"status": 500  
}

If I change the interval to be 1.0 or greater, it works. But, I want  
intervals of 0.1...

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b8dad371-dfef-4c57-b7d8-433ee1c308c6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b8dad371-dfef-4c57-b7d8-433ee1c308c6%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [October 27, 2014, 5:14pm UTC](https://discuss.elastic.co/t/histogram-aggregation-with-float-interval-1-0-gives-arithmeticexception/20447/2 "2014-10-27T17:14:08Z")

</div>

Hi Mark,

This is unfortunately a known limitation of histograms today: they only  
work with integer intervals.

> <https://github.com/elastic/elasticsearch/issues/4847>
>
> Fork of #3810 and #3799. Decimal intervals would be useful for certain data type…s such as currencies, temperatures, lengths ...

On Mon, Oct 27, 2014 at 1:17 PM, LiquidMark [mark.e.molloy@gmail.com](mailto:mark.e.molloy@gmail.com) wrote:

> Hi, the following query (note bolded line):
> 
> {  
> "query": {  
> "filtered": {  
> "query": {  
> "term": {  
> "self\_and\_ancestors": "diamonds"  
> }  
> },  
> "filter": {  
> "terms": {  
> "attr\_types.diamond#color": [  
> "0000d"  
> ]  
> }  
> }  
> }  
> },  
> "sort": [  
> {  
> "sell\_offer\_cents": {  
> "order": "asc"  
> }  
> }  
> ],  
> "fields": "\_source",  
> "script\_fields": {  
> "gap\_cents": {  
> "script": "custom\_score\_item\_bid\_ask\_gap",  
> "params": {  
> "individual\_price\_item\_ids": ,  
> "individual\_price\_item\_cents": ,  
> "pb\_amount\_below\_cents": 0  
> },  
> "lang": "native"  
> }  
> },  
> "aggs": {  
> "all\_items": {  
> "global": {},  
> "aggs": {  
> "gem#carats": {  
> "filter": {  
> "terms": {  
> "attr\_types.diamond#polish": [  
> "0000ex",  
> "0001vg"  
> ]  
> }  
> },  
> "aggs": {  
> "gems#carats": {  
> "histogram": {  
> "field": "attr\_types.gem#carats",  
> \* "interval": 0.1,\*  
> "min\_doc\_count": 0  
> }  
> },  
> "gem#carats\_stats": {  
> "stats": {  
> "field": "attr\_types.gem#carats"  
> }  
> }  
> }  
> }  
> }  
> }  
> }  
> }
> 
> Gives the following error:
> 
> {  
> "error": "SearchPhaseExecutionException[Failed to execute phase  
> [query], all shards failed; shardFailures  
> {[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][4]:  
> QueryPhaseExecutionException[[development-liquidibles::application-items][4]:  
> query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
> org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@11ce49a\>]:  
> Query Failed [Failed to execute global aggregators]]; nested:  
> ArithmeticException;  
> }{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][3]:  
> QueryPhaseExecutionException[[development-liquidibles::application-items][3]:  
> query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
> org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@8c9d82\>]:  
> Query Failed [Failed to execute global aggregators]]; nested:  
> ArithmeticException;  
> }{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][2]:  
> QueryPhaseExecutionException[[development-liquidibles::application-items][2]:  
> query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
> org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@73a7e5\>]:  
> Query Failed [Failed to execute global aggregators]]; nested:  
> ArithmeticException;  
> }{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][1]:  
> QueryPhaseExecutionException[[development-liquidibles::application-items][1]:  
> query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
> org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@15d1b1a\>]:  
> Query Failed [Failed to execute global aggregators]]; nested:  
> ArithmeticException;  
> }{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][0]:  
> QueryPhaseExecutionException[[development-liquidibles::application-items][0]:  
> query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
> org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@1b8c216\>]:  
> Query Failed [Failed to execute global aggregators]]; nested:  
> _ArithmeticException_; }]",  
> "status": 500  
> }
> 
> If I change the interval to be 1.0 or greater, it works. But, I want  
> intervals of 0.1...
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/b8dad371-dfef-4c57-b7d8-433ee1c308c6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b8dad371-dfef-4c57-b7d8-433ee1c308c6%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/b8dad371-dfef-4c57-b7d8-433ee1c308c6%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b8dad371-dfef-4c57-b7d8-433ee1c308c6%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5oOcmh-Ne3tpoBNqaMpStskZzAYJch6R%2BtPz7hzVQV3g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5oOcmh-Ne3tpoBNqaMpStskZzAYJch6R%2BtPz7hzVQV3g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![LiquidMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/liquidmark/32/1151_2.png) [@LiquidMark](https://discuss.elastic.co/u/LiquidMark)\
**Post date:** [October 27, 2014, 11:22pm UTC](https://discuss.elastic.co/t/histogram-aggregation-with-float-interval-1-0-gives-arithmeticexception/20447/3 "2014-10-27T23:22:13Z")

</div>

Hi Adrien,

Thanks for letting me know!

-Mark

On Mon, Oct 27, 2014 at 12:14 PM, Adrien Grand \<  
[adrien.grand@elasticsearch.com](mailto:adrien.grand@elasticsearch.com)\> wrote:

> Hi Mark,
> 
> This is unfortunately a known limitation of histograms today: they only  
> work with integer intervals.
> 
> [Histogram aggregations: support decimal intervals · Issue #4847 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/4847)
> 
> On Mon, Oct 27, 2014 at 1:17 PM, LiquidMark [mark.e.molloy@gmail.com](mailto:mark.e.molloy@gmail.com)  
> wrote:
> 
> > Hi, the following query (note bolded line):
> > 
> > {  
> > "query": {  
> > "filtered": {  
> > "query": {  
> > "term": {  
> > "self\_and\_ancestors": "diamonds"  
> > }  
> > },  
> > "filter": {  
> > "terms": {  
> > "attr\_types.diamond#color": [  
> > "0000d"  
> > ]  
> > }  
> > }  
> > }  
> > },  
> > "sort": [  
> > {  
> > "sell\_offer\_cents": {  
> > "order": "asc"  
> > }  
> > }  
> > ],  
> > "fields": "\_source",  
> > "script\_fields": {  
> > "gap\_cents": {  
> > "script": "custom\_score\_item\_bid\_ask\_gap",  
> > "params": {  
> > "individual\_price\_item\_ids": ,  
> > "individual\_price\_item\_cents": ,  
> > "pb\_amount\_below\_cents": 0  
> > },  
> > "lang": "native"  
> > }  
> > },  
> > "aggs": {  
> > "all\_items": {  
> > "global": {},  
> > "aggs": {  
> > "gem#carats": {  
> > "filter": {  
> > "terms": {  
> > "attr\_types.diamond#polish": [  
> > "0000ex",  
> > "0001vg"  
> > ]  
> > }  
> > },  
> > "aggs": {  
> > "gems#carats": {  
> > "histogram": {  
> > "field": "attr\_types.gem#carats",  
> > \* "interval": 0.1,\*  
> > "min\_doc\_count": 0  
> > }  
> > },  
> > "gem#carats\_stats": {  
> > "stats": {  
> > "field": "attr\_types.gem#carats"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > Gives the following error:
> > 
> > {  
> > "error": "SearchPhaseExecutionException[Failed to execute phase  
> > [query], all shards failed; shardFailures  
> > {[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][4]:  
> > QueryPhaseExecutionException[[development-liquidibles::application-items][4]:  
> > query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
> > org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@11ce49a\>]:  
> > Query Failed [Failed to execute global aggregators]]; nested:  
> > ArithmeticException;  
> > }{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][3]:  
> > QueryPhaseExecutionException[[development-liquidibles::application-items][3]:  
> > query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
> > org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@8c9d82\>]:  
> > Query Failed [Failed to execute global aggregators]]; nested:  
> > ArithmeticException;  
> > }{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][2]:  
> > QueryPhaseExecutionException[[development-liquidibles::application-items][2]:  
> > query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
> > org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@73a7e5\>]:  
> > Query Failed [Failed to execute global aggregators]]; nested:  
> > ArithmeticException;  
> > }{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][1]:  
> > QueryPhaseExecutionException[[development-liquidibles::application-items][1]:  
> > query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
> > org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@15d1b1a\>]:  
> > Query Failed [Failed to execute global aggregators]]; nested:  
> > ArithmeticException;  
> > }{[D6h8GKwjRqO\_Yem09Hu\_VA][development-liquidibles::application-items][0]:  
> > QueryPhaseExecutionException[[development-liquidibles::application-items][0]:  
> > query[filtered(filtered(self\_and\_ancestors:diamonds)-\>cache(attr\_types.diamond#color:0000d))-\>cache(\_type:item)],from[0],size[10],sort[\<custom:"sell\_offer\_cents":  
> > org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@1b8c216\>]:  
> > Query Failed [Failed to execute global aggregators]]; nested:  
> > _ArithmeticException_; }]",  
> > "status": 500  
> > }
> > 
> > If I change the interval to be 1.0 or greater, it works. But, I want  
> > intervals of 0.1...
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/b8dad371-dfef-4c57-b7d8-433ee1c308c6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b8dad371-dfef-4c57-b7d8-433ee1c308c6%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/b8dad371-dfef-4c57-b7d8-433ee1c308c6%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b8dad371-dfef-4c57-b7d8-433ee1c308c6%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Adrien Grand
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/nlY-XY3PBd8/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nlY-XY3PBd8/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5oOcmh-Ne3tpoBNqaMpStskZzAYJch6R%2BtPz7hzVQV3g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5oOcmh-Ne3tpoBNqaMpStskZzAYJch6R%2BtPz7hzVQV3g%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5oOcmh-Ne3tpoBNqaMpStskZzAYJch6R%2BtPz7hzVQV3g%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5oOcmh-Ne3tpoBNqaMpStskZzAYJch6R%2BtPz7hzVQV3g%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--

- Mark Molloy  
(641)218-8265

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALL%2BC8DPDUMPj2jKzuSZHXg4jkR6jM90XbW0cVwQK8WAbT\_3GQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALL%2BC8DPDUMPj2jKzuSZHXg4jkR6jM90XbW0cVwQK8WAbT_3GQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:53am UTC](https://discuss.elastic.co/t/histogram-aggregation-with-float-interval-1-0-gives-arithmeticexception/20447/4 "2017-07-06T00:53:37Z")

</div>


