# Geo bounds aggregation as a sub aggregator?

**URL:** <https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856>\
**Category:** Elasticsearch\
**Created:** [July 24, 2014, 6:46am UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856 "2014-07-24T06:46:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![svartalf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/svartalf/32/1379_2.png) [@svartalf](https://discuss.elastic.co/u/svartalf)\
**Post date:** [July 24, 2014, 6:46am UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856/1 "2014-07-24T06:46:31Z")

</div>

Is there any way to use geo\_bounds as a sub aggregator?

I have a geohash\_grid aggregation, and it will be very useful to get bounds  
for each bucket of the data.  
Right now my ES 1.3.0 says that he "Could not find aggregator type [bounds]  
in [aggregations]]".

--  
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/ef8b87ad-5c5e-4d50-b87d-9ac9d6659048%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ef8b87ad-5c5e-4d50-b87d-9ac9d6659048%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [July 24, 2014, 7:52am UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856/2 "2014-07-24T07:52:01Z")

</div>

You should be able to achieve this with the below query. If you still  
cannot get it working could you provide a cURL example which reproduces  
your issue?

curl -XGET "[http://localhost:9200/geo/\_search](http://localhost:9200/geo/_search)" -d'  
{  
"size": 0,  
"aggs": {  
"geohash" : {  
"geohash\_grid": {  
"field": "location",  
"precision": 3  
},  
"aggs": {  
"subbounds": {  
"geo\_bounds": {  
"field": "location"  
}  
}  
}  
}  
}  
}'

On Thursday, 24 July 2014 07:46:31 UTC+1, svartalf wrote:

> Is there any way to use geo\_bounds as a sub aggregator?
> 
> I have a geohash\_grid aggregation, and it will be very useful to get  
> bounds for each bucket of the data.  
> Right now my ES 1.3.0 says that he "Could not find aggregator type  
> [bounds] in [aggregations]]".

--  
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/bf7f3770-f8f5-453e-bcf8-8321ca6a8f12%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bf7f3770-f8f5-453e-bcf8-8321ca6a8f12%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![svartalf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/svartalf/32/1379_2.png) [@svartalf](https://discuss.elastic.co/u/svartalf)\
**Post date:** [July 24, 2014, 8:32am UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856/3 "2014-07-24T08:32:10Z")

</div>

Here is an example: [request.sh · GitHub](https://gist.github.com/svartalf/c3cb76c40dd4fa1374fa)

I'm using two inner aggregation functions, and with "top\_hits" removed,  
"geo\_bounds" works sometimes, and sometimes fails with a `response_2.json`  
(in the example) or `response_3.json`.  
With an enabled "top\_hits" aggregator it is also throwing `response_1.json`  
text.

I'm trying to group points into the buckets and annotate them with a  
top\_hit item and geo bounds for each bucket, and got stuck a little. Maybe  
I should move one of those two aggregations one level deeper?

четверг, 24 июля 2014 г., 16:52:01 UTC+9 пользователь Colin  
Goodheart-Smithe написал:

> You should be able to achieve this with the below query. If you still  
> cannot get it working could you provide a cURL example which reproduces  
> your issue?
> 
> curl -XGET "[http://localhost:9200/geo/\_search](http://localhost:9200/geo/_search)" -d'  
> {  
> "size": 0,  
> "aggs": {  
> "geohash" : {  
> "geohash\_grid": {  
> "field": "location",  
> "precision": 3  
> },  
> "aggs": {  
> "subbounds": {  
> "geo\_bounds": {  
> "field": "location"  
> }  
> }  
> }  
> }  
> }  
> }'
> 
> On Thursday, 24 July 2014 07:46:31 UTC+1, svartalf wrote:
> 
> > Is there any way to use geo\_bounds as a sub aggregator?
> > 
> > I have a geohash\_grid aggregation, and it will be very useful to get  
> > bounds for each bucket of the data.  
> > Right now my ES 1.3.0 says that he "Could not find aggregator type  
> > [bounds] in [aggregations]]".

--  
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/56e9cab5-a054-4c01-a661-c05d41488ae9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/56e9cab5-a054-4c01-a661-c05d41488ae9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [July 24, 2014, 9:05am UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856/4 "2014-07-24T09:05:29Z")

</div>

I think the problem is that you have an extra aggregations object  
surrounding the geo\_bounds aggregation. Try the following:

curl -XGET "[http://localhost:9200/postings/\_search](http://localhost:9200/postings/_search)" -d'  
{  
"query": {  
"filtered": {  
"filter": {  
"geo\_bounding\_box": {  
"point": {  
"bottom\_right": [  
104.45856200712711,  
52.208730692828844  
],  
"top\_left": [  
104.19077025908017,  
52.34035674074375  
]  
}  
}  
},  
"query": {  
"match\_all": {}  
}  
}  
},  
"aggregations": {  
"cells": {  
"geohash\_grid": {  
"field": "point",  
"precision": 6  
},  
"aggregations": {  
"lat": {  
"avg": {  
"script": "doc["point"].lat"  
}  
},  
"lon": {  
"avg": {  
"script": "doc["point"].lon"  
}  
},  
"hits": {  
"top\_hits": {  
"\_source": {  
"include": [  
"short\_description"  
]  
},  
"size": 1  
}  
},  
"bounds": {  
"geo\_bounds": {  
"field": "point"  
}  
}  
}  
}  
},  
"size": 0  
}'

On Thursday, 24 July 2014 09:32:10 UTC+1, svartalf wrote:

> Here is an example: [request.sh · GitHub](https://gist.github.com/svartalf/c3cb76c40dd4fa1374fa)
> 
> I'm using two inner aggregation functions, and with "top\_hits" removed,  
> "geo\_bounds" works sometimes, and sometimes fails with a `response_2.json`  
> (in the example) or `response_3.json`.  
> With an enabled "top\_hits" aggregator it is also throwing  
> `response_1.json` text.
> 
> I'm trying to group points into the buckets and annotate them with a  
> top\_hit item and geo bounds for each bucket, and got stuck a little. Maybe  
> I should move one of those two aggregations one level deeper?
> 
> четверг, 24 июля 2014 г., 16:52:01 UTC+9 пользователь Colin  
> Goodheart-Smithe написал:
> 
> > You should be able to achieve this with the below query. If you still  
> > cannot get it working could you provide a cURL example which reproduces  
> > your issue?
> > 
> > curl -XGET "[http://localhost:9200/geo/\_search](http://localhost:9200/geo/_search)" -d'  
> > {  
> > "size": 0,  
> > "aggs": {  
> > "geohash" : {  
> > "geohash\_grid": {  
> > "field": "location",  
> > "precision": 3  
> > },  
> > "aggs": {  
> > "subbounds": {  
> > "geo\_bounds": {  
> > "field": "location"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }'
> > 
> > On Thursday, 24 July 2014 07:46:31 UTC+1, svartalf wrote:
> > 
> > > Is there any way to use geo\_bounds as a sub aggregator?
> > > 
> > > I have a geohash\_grid aggregation, and it will be very useful to get  
> > > bounds for each bucket of the data.  
> > > Right now my ES 1.3.0 says that he "Could not find aggregator type  
> > > [bounds] in [aggregations]]".

--  
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/fd12bf52-9f3f-450c-a13d-547eef4fb926%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fd12bf52-9f3f-450c-a13d-547eef4fb926%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![svartalf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/svartalf/32/1379_2.png) [@svartalf](https://discuss.elastic.co/u/svartalf)\
**Post date:** [July 25, 2014, 12:18am UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856/5 "2014-07-25T00:18:49Z")

</div>

It is really odd, but it failed for me on the precision levels 6 and 7 with  
a ArrayIndexOutOfBoundsException, and working for 5 and 8 levels.

I had put a big query examples here:

> <https://gist.github.com/svartalf/5db600e7ea2907fbda3a>
>
> There are more than three files. show original

четверг, 24 июля 2014 г., 18:05:30 UTC+9 пользователь Colin  
Goodheart-Smithe написал:

> I think the problem is that you have an extra aggregations object  
> surrounding the geo\_bounds aggregation. Try the following:
> 
> curl -XGET "[http://localhost:9200/postings/\_search](http://localhost:9200/postings/_search)" -d'  
> {  
> "query": {  
> "filtered": {  
> "filter": {  
> "geo\_bounding\_box": {  
> "point": {  
> "bottom\_right": [  
> 104.45856200712711,  
> 52.208730692828844  
> ],  
> "top\_left": [  
> 104.19077025908017,  
> 52.34035674074375  
> ]  
> }  
> }  
> },  
> "query": {  
> "match\_all": {}  
> }  
> }  
> },  
> "aggregations": {  
> "cells": {  
> "geohash\_grid": {  
> "field": "point",  
> "precision": 6  
> },  
> "aggregations": {  
> "lat": {  
> "avg": {  
> "script": "doc["point"].lat"  
> }  
> },  
> "lon": {  
> "avg": {  
> "script": "doc["point"].lon"  
> }  
> },  
> "hits": {  
> "top\_hits": {  
> "\_source": {  
> "include": [  
> "short\_description"  
> ]  
> },  
> "size": 1  
> }  
> },  
> "bounds": {  
> "geo\_bounds": {  
> "field": "point"  
> }  
> }  
> }  
> }  
> },  
> "size": 0  
> }'
> 
> On Thursday, 24 July 2014 09:32:10 UTC+1, svartalf wrote:
> 
> > Here is an example: [request.sh · GitHub](https://gist.github.com/svartalf/c3cb76c40dd4fa1374fa)
> > 
> > I'm using two inner aggregation functions, and with "top\_hits" removed,  
> > "geo\_bounds" works sometimes, and sometimes fails with a `response_2.json`  
> > (in the example) or `response_3.json`.  
> > With an enabled "top\_hits" aggregator it is also throwing  
> > `response_1.json` text.
> > 
> > I'm trying to group points into the buckets and annotate them with a  
> > top\_hit item and geo bounds for each bucket, and got stuck a little. Maybe  
> > I should move one of those two aggregations one level deeper?
> > 
> > четверг, 24 июля 2014 г., 16:52:01 UTC+9 пользователь Colin  
> > Goodheart-Smithe написал:
> > 
> > > You should be able to achieve this with the below query. If you still  
> > > cannot get it working could you provide a cURL example which reproduces  
> > > your issue?
> > > 
> > > curl -XGET "[http://localhost:9200/geo/\_search](http://localhost:9200/geo/_search)" -d'  
> > > {  
> > > "size": 0,  
> > > "aggs": {  
> > > "geohash" : {  
> > > "geohash\_grid": {  
> > > "field": "location",  
> > > "precision": 3  
> > > },  
> > > "aggs": {  
> > > "subbounds": {  
> > > "geo\_bounds": {  
> > > "field": "location"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }'
> > > 
> > > On Thursday, 24 July 2014 07:46:31 UTC+1, svartalf wrote:
> > > 
> > > > Is there any way to use geo\_bounds as a sub aggregator?
> > > > 
> > > > I have a geohash\_grid aggregation, and it will be very useful to get  
> > > > bounds for each bucket of the data.  
> > > > Right now my ES 1.3.0 says that he "Could not find aggregator type  
> > > > [bounds] in [aggregations]]".

--  
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/f9bffce5-466f-4de6-b393-b8a5a3ece773%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f9bffce5-466f-4de6-b393-b8a5a3ece773%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [July 25, 2014, 1:47pm UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856/6 "2014-07-25T13:47:39Z")

</div>

Could you post the full stack trace from the elasticsearch log file? This  
will help in working out where the query falls over

Thanks

On Friday, 25 July 2014 01:18:49 UTC+1, svartalf wrote:

> It is really odd, but it failed for me on the precision levels 6 and 7  
> with a ArrayIndexOutOfBoundsException, and working for 5 and 8 levels.
> 
> I had put a big query examples here:  
> [ElasticSearch geo\_bounds aggregation failure on precision levels 6 and 7 · GitHub](https://gist.github.com/svartalf/5db600e7ea2907fbda3a)
> 
> четверг, 24 июля 2014 г., 18:05:30 UTC+9 пользователь Colin  
> Goodheart-Smithe написал:
> 
> > I think the problem is that you have an extra aggregations object  
> > surrounding the geo\_bounds aggregation. Try the following:
> > 
> > curl -XGET "[http://localhost:9200/postings/\_search](http://localhost:9200/postings/_search)" -d'  
> > {  
> > "query": {  
> > "filtered": {  
> > "filter": {  
> > "geo\_bounding\_box": {  
> > "point": {  
> > "bottom\_right": [  
> > 104.45856200712711,  
> > 52.208730692828844  
> > ],  
> > "top\_left": [  
> > 104.19077025908017,  
> > 52.34035674074375  
> > ]  
> > }  
> > }  
> > },  
> > "query": {  
> > "match\_all": {}  
> > }  
> > }  
> > },  
> > "aggregations": {  
> > "cells": {  
> > "geohash\_grid": {  
> > "field": "point",  
> > "precision": 6  
> > },  
> > "aggregations": {  
> > "lat": {  
> > "avg": {  
> > "script": "doc["point"].lat"  
> > }  
> > },  
> > "lon": {  
> > "avg": {  
> > "script": "doc["point"].lon"  
> > }  
> > },  
> > "hits": {  
> > "top\_hits": {  
> > "\_source": {  
> > "include": [  
> > "short\_description"  
> > ]  
> > },  
> > "size": 1  
> > }  
> > },  
> > "bounds": {  
> > "geo\_bounds": {  
> > "field": "point"  
> > }  
> > }  
> > }  
> > }  
> > },  
> > "size": 0  
> > }'
> > 
> > On Thursday, 24 July 2014 09:32:10 UTC+1, svartalf wrote:
> > 
> > > Here is an example:  
> > > [request.sh · GitHub](https://gist.github.com/svartalf/c3cb76c40dd4fa1374fa)
> > > 
> > > I'm using two inner aggregation functions, and with "top\_hits" removed,  
> > > "geo\_bounds" works sometimes, and sometimes fails with a `response_2.json`  
> > > (in the example) or `response_3.json`.  
> > > With an enabled "top\_hits" aggregator it is also throwing  
> > > `response_1.json` text.
> > > 
> > > I'm trying to group points into the buckets and annotate them with a  
> > > top\_hit item and geo bounds for each bucket, and got stuck a little. Maybe  
> > > I should move one of those two aggregations one level deeper?
> > > 
> > > четверг, 24 июля 2014 г., 16:52:01 UTC+9 пользователь Colin  
> > > Goodheart-Smithe написал:
> > > 
> > > > You should be able to achieve this with the below query. If you still  
> > > > cannot get it working could you provide a cURL example which reproduces  
> > > > your issue?
> > > > 
> > > > curl -XGET "[http://localhost:9200/geo/\_search](http://localhost:9200/geo/_search)" -d'  
> > > > {  
> > > > "size": 0,  
> > > > "aggs": {  
> > > > "geohash" : {  
> > > > "geohash\_grid": {  
> > > > "field": "location",  
> > > > "precision": 3  
> > > > },  
> > > > "aggs": {  
> > > > "subbounds": {  
> > > > "geo\_bounds": {  
> > > > "field": "location"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }'
> > > > 
> > > > On Thursday, 24 July 2014 07:46:31 UTC+1, svartalf wrote:
> > > > 
> > > > > Is there any way to use geo\_bounds as a sub aggregator?
> > > > > 
> > > > > I have a geohash\_grid aggregation, and it will be very useful to get  
> > > > > bounds for each bucket of the data.  
> > > > > Right now my ES 1.3.0 says that he "Could not find aggregator type  
> > > > > [bounds] in [aggregations]]".

--  
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/fd5f89e9-db00-4e8a-94c0-40a8c26a48ac%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fd5f89e9-db00-4e8a-94c0-40a8c26a48ac%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![owainb](https://avatars.discourse-cdn.com/v4/letter/o/e99b99/32.png) [@owainb](https://discuss.elastic.co/u/owainb)\
**Post date:** [September 2, 2014, 2:23pm UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856/7 "2014-09-02T14:23:23Z")

</div>

Hi,

I hit exactly the same issue today. It seems that the problem occurs when  
the number of buckets in the outer geohash grid aggregation goes above a  
certain number (around 50 in my tests but that could be system dependent).  
The stack trace is below but doesn't tell much. If someone can confirm this  
is a bug I am happy to raise an issue.

[2014-09-02 14:46:54,698][DEBUG][action.search.type] [3-D Man]  
[typename][0], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
[true]  
org.elasticsearch.search.query.QueryPhaseExecutionException: [typename][0]:  
query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
Query Failed [Failed to execute main query]  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:744)  
Caused by: java.lang.ArrayIndexOutOfBoundsException  
[2014-09-02 14:46:54,699][DEBUG][action.search.type] [3-D Man]  
[typename][3], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
[true]  
org.elasticsearch.search.query.QueryPhaseExecutionException: [typename][3]:  
query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
Query Failed [Failed to execute main query]  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:744)  
Caused by: java.lang.ArrayIndexOutOfBoundsException  
[2014-09-02 14:46:54,707][DEBUG][action.search.type] [3-D Man]  
[typename][4], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
[true]  
org.elasticsearch.search.query.QueryPhaseExecutionException: [typename][4]:  
query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
Query Failed [Failed to execute main query]  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:744)  
Caused by: java.lang.ArrayIndexOutOfBoundsException  
[2014-09-02 14:46:54,708][DEBUG][action.search.type] [3-D Man]  
[typename][1], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
[true]  
org.elasticsearch.search.query.QueryPhaseExecutionException: [typename][1]:  
query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
Query Failed [Failed to execute main query]  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:744)  
Caused by: java.lang.ArrayIndexOutOfBoundsException  
[2014-09-02 14:46:54,713][DEBUG][action.search.type] [3-D Man]  
[typename][2], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
execute [org.elasticsearch.action.search.SearchRequest@37a97844]  
org.elasticsearch.search.query.QueryPhaseExecutionException: [typename][2]:  
query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
Query Failed [Failed to execute main query]  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:744)  
Caused by: java.lang.ArrayIndexOutOfBoundsException  
[2014-09-02 14:46:54,714][DEBUG][action.search.type] [3-D Man] All  
shards failed for phase: [query]

On Friday, July 25, 2014 2:47:39 PM UTC+1, Colin Goodheart-Smithe wrote:

> Could you post the full stack trace from the elasticsearch log file? This  
> will help in working out where the query falls over
> 
> Thanks
> 
> On Friday, 25 July 2014 01:18:49 UTC+1, svartalf wrote:
> 
> > It is really odd, but it failed for me on the precision levels 6 and 7  
> > with a ArrayIndexOutOfBoundsException, and working for 5 and 8 levels.
> > 
> > I had put a big query examples here:  
> > [ElasticSearch geo\_bounds aggregation failure on precision levels 6 and 7 · GitHub](https://gist.github.com/svartalf/5db600e7ea2907fbda3a)
> > 
> > четверг, 24 июля 2014 г., 18:05:30 UTC+9 пользователь Colin  
> > Goodheart-Smithe написал:
> > 
> > > I think the problem is that you have an extra aggregations object  
> > > surrounding the geo\_bounds aggregation. Try the following:
> > > 
> > > curl -XGET "[http://localhost:9200/postings/\_search](http://localhost:9200/postings/_search)" -d'  
> > > {  
> > > "query": {  
> > > "filtered": {  
> > > "filter": {  
> > > "geo\_bounding\_box": {  
> > > "point": {  
> > > "bottom\_right": [  
> > > 104.45856200712711,  
> > > 52.208730692828844  
> > > ],  
> > > "top\_left": [  
> > > 104.19077025908017,  
> > > 52.34035674074375  
> > > ]  
> > > }  
> > > }  
> > > },  
> > > "query": {  
> > > "match\_all": {}  
> > > }  
> > > }  
> > > },  
> > > "aggregations": {  
> > > "cells": {  
> > > "geohash\_grid": {  
> > > "field": "point",  
> > > "precision": 6  
> > > },  
> > > "aggregations": {  
> > > "lat": {  
> > > "avg": {  
> > > "script": "doc["point"].lat"  
> > > }  
> > > },  
> > > "lon": {  
> > > "avg": {  
> > > "script": "doc["point"].lon"  
> > > }  
> > > },  
> > > "hits": {  
> > > "top\_hits": {  
> > > "\_source": {  
> > > "include": [  
> > > "short\_description"  
> > > ]  
> > > },  
> > > "size": 1  
> > > }  
> > > },  
> > > "bounds": {  
> > > "geo\_bounds": {  
> > > "field": "point"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > },  
> > > "size": 0  
> > > }'
> > > 
> > > On Thursday, 24 July 2014 09:32:10 UTC+1, svartalf wrote:
> > > 
> > > > Here is an example:  
> > > > [request.sh · GitHub](https://gist.github.com/svartalf/c3cb76c40dd4fa1374fa)
> > > > 
> > > > I'm using two inner aggregation functions, and with "top\_hits" removed,  
> > > > "geo\_bounds" works sometimes, and sometimes fails with a `response_2.json`  
> > > > (in the example) or `response_3.json`.  
> > > > With an enabled "top\_hits" aggregator it is also throwing  
> > > > `response_1.json` text.
> > > > 
> > > > I'm trying to group points into the buckets and annotate them with a  
> > > > top\_hit item and geo bounds for each bucket, and got stuck a little. Maybe  
> > > > I should move one of those two aggregations one level deeper?
> > > > 
> > > > четверг, 24 июля 2014 г., 16:52:01 UTC+9 пользователь Colin  
> > > > Goodheart-Smithe написал:
> > > > 
> > > > > You should be able to achieve this with the below query. If you still  
> > > > > cannot get it working could you provide a cURL example which reproduces  
> > > > > your issue?
> > > > > 
> > > > > curl -XGET "[http://localhost:9200/geo/\_search](http://localhost:9200/geo/_search)" -d'  
> > > > > {  
> > > > > "size": 0,  
> > > > > "aggs": {  
> > > > > "geohash" : {  
> > > > > "geohash\_grid": {  
> > > > > "field": "location",  
> > > > > "precision": 3  
> > > > > },  
> > > > > "aggs": {  
> > > > > "subbounds": {  
> > > > > "geo\_bounds": {  
> > > > > "field": "location"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }'
> > > > > 
> > > > > On Thursday, 24 July 2014 07:46:31 UTC+1, svartalf wrote:
> > > > > 
> > > > > > Is there any way to use geo\_bounds as a sub aggregator?
> > > > > > 
> > > > > > I have a geohash\_grid aggregation, and it will be very useful to get  
> > > > > > bounds for each bucket of the data.  
> > > > > > Right now my ES 1.3.0 says that he "Could not find aggregator type  
> > > > > > [bounds] in [aggregations]]".

--  
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/599912f7-7280-4f5a-8400-4eed0a587385%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/599912f7-7280-4f5a-8400-4eed0a587385%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [September 2, 2014, 2:30pm UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856/8 "2014-09-02T14:30:54Z")

</div>

Ok, yes this does look like a bug so if you could raise an issue on github  
and post the issue link back in this thread, that would be great.

Thanks

Colin

On Tuesday, 2 September 2014 15:23:23 UTC+1, Owain Braddick wrote:

> Hi,
> 
> I hit exactly the same issue today. It seems that the problem occurs when  
> the number of buckets in the outer geohash grid aggregation goes above a  
> certain number (around 50 in my tests but that could be system dependent).  
> The stack trace is below but doesn't tell much. If someone can confirm this  
> is a bug I am happy to raise an issue.
> 
> [2014-09-02 14:46:54,698][DEBUG][action.search.type] [3-D Man]  
> [typename][0], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
> [true]  
> org.elasticsearch.search.query.QueryPhaseExecutionException:  
> [typename][0]:  
> query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> Query Failed [Failed to execute main query]  
> at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> at  
> org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> at java.lang.Thread.run(Thread.java:744)  
> Caused by: java.lang.ArrayIndexOutOfBoundsException  
> [2014-09-02 14:46:54,699][DEBUG][action.search.type] [3-D Man]  
> [typename][3], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
> [true]  
> org.elasticsearch.search.query.QueryPhaseExecutionException:  
> [typename][3]:  
> query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> Query Failed [Failed to execute main query]  
> at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> at  
> org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> at java.lang.Thread.run(Thread.java:744)  
> Caused by: java.lang.ArrayIndexOutOfBoundsException  
> [2014-09-02 14:46:54,707][DEBUG][action.search.type] [3-D Man]  
> [typename][4], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
> [true]  
> org.elasticsearch.search.query.QueryPhaseExecutionException:  
> [typename][4]:  
> query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> Query Failed [Failed to execute main query]  
> at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> at  
> org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> at java.lang.Thread.run(Thread.java:744)  
> Caused by: java.lang.ArrayIndexOutOfBoundsException  
> [2014-09-02 14:46:54,708][DEBUG][action.search.type] [3-D Man]  
> [typename][1], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
> [true]  
> org.elasticsearch.search.query.QueryPhaseExecutionException:  
> [typename][1]:  
> query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> Query Failed [Failed to execute main query]  
> at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> at  
> org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> at java.lang.Thread.run(Thread.java:744)  
> Caused by: java.lang.ArrayIndexOutOfBoundsException  
> [2014-09-02 14:46:54,713][DEBUG][action.search.type] [3-D Man]  
> [typename][2], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> execute [org.elasticsearch.action.search.SearchRequest@37a97844]  
> org.elasticsearch.search.query.QueryPhaseExecutionException:  
> [typename][2]:  
> query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> Query Failed [Failed to execute main query]  
> at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> at  
> org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> at java.lang.Thread.run(Thread.java:744)  
> Caused by: java.lang.ArrayIndexOutOfBoundsException  
> [2014-09-02 14:46:54,714][DEBUG][action.search.type] [3-D Man] All  
> shards failed for phase: [query]
> 
> On Friday, July 25, 2014 2:47:39 PM UTC+1, Colin Goodheart-Smithe wrote:
> 
> > Could you post the full stack trace from the elasticsearch log file? This  
> > will help in working out where the query falls over
> > 
> > Thanks
> > 
> > On Friday, 25 July 2014 01:18:49 UTC+1, svartalf wrote:
> > 
> > > It is really odd, but it failed for me on the precision levels 6 and 7  
> > > with a ArrayIndexOutOfBoundsException, and working for 5 and 8 levels.
> > > 
> > > I had put a big query examples here:  
> > > [ElasticSearch geo\_bounds aggregation failure on precision levels 6 and 7 · GitHub](https://gist.github.com/svartalf/5db600e7ea2907fbda3a)
> > > 
> > > четверг, 24 июля 2014 г., 18:05:30 UTC+9 пользователь Colin  
> > > Goodheart-Smithe написал:
> > > 
> > > > I think the problem is that you have an extra aggregations object  
> > > > surrounding the geo\_bounds aggregation. Try the following:
> > > > 
> > > > curl -XGET "[http://localhost:9200/postings/\_search](http://localhost:9200/postings/_search)" -d'  
> > > > {  
> > > > "query": {  
> > > > "filtered": {  
> > > > "filter": {  
> > > > "geo\_bounding\_box": {  
> > > > "point": {  
> > > > "bottom\_right": [  
> > > > 104.45856200712711,  
> > > > 52.208730692828844  
> > > > ],  
> > > > "top\_left": [  
> > > > 104.19077025908017,  
> > > > 52.34035674074375  
> > > > ]  
> > > > }  
> > > > }  
> > > > },  
> > > > "query": {  
> > > > "match\_all": {}  
> > > > }  
> > > > }  
> > > > },  
> > > > "aggregations": {  
> > > > "cells": {  
> > > > "geohash\_grid": {  
> > > > "field": "point",  
> > > > "precision": 6  
> > > > },  
> > > > "aggregations": {  
> > > > "lat": {  
> > > > "avg": {  
> > > > "script": "doc["point"].lat"  
> > > > }  
> > > > },  
> > > > "lon": {  
> > > > "avg": {  
> > > > "script": "doc["point"].lon"  
> > > > }  
> > > > },  
> > > > "hits": {  
> > > > "top\_hits": {  
> > > > "\_source": {  
> > > > "include": [  
> > > > "short\_description"  
> > > > ]  
> > > > },  
> > > > "size": 1  
> > > > }  
> > > > },  
> > > > "bounds": {  
> > > > "geo\_bounds": {  
> > > > "field": "point"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > },  
> > > > "size": 0  
> > > > }'
> > > > 
> > > > On Thursday, 24 July 2014 09:32:10 UTC+1, svartalf wrote:
> > > > 
> > > > > Here is an example:  
> > > > > [request.sh · GitHub](https://gist.github.com/svartalf/c3cb76c40dd4fa1374fa)
> > > > > 
> > > > > I'm using two inner aggregation functions, and with "top\_hits"  
> > > > > removed, "geo\_bounds" works sometimes, and sometimes fails with a  
> > > > > `response_2.json` (in the example) or `response_3.json`.  
> > > > > With an enabled "top\_hits" aggregator it is also throwing  
> > > > > `response_1.json` text.
> > > > > 
> > > > > I'm trying to group points into the buckets and annotate them with a  
> > > > > top\_hit item and geo bounds for each bucket, and got stuck a little. Maybe  
> > > > > I should move one of those two aggregations one level deeper?
> > > > > 
> > > > > четверг, 24 июля 2014 г., 16:52:01 UTC+9 пользователь Colin  
> > > > > Goodheart-Smithe написал:
> > > > > 
> > > > > > You should be able to achieve this with the below query. If you  
> > > > > > still cannot get it working could you provide a cURL example which  
> > > > > > reproduces your issue?
> > > > > > 
> > > > > > curl -XGET "[http://localhost:9200/geo/\_search](http://localhost:9200/geo/_search)" -d'  
> > > > > > {  
> > > > > > "size": 0,  
> > > > > > "aggs": {  
> > > > > > "geohash" : {  
> > > > > > "geohash\_grid": {  
> > > > > > "field": "location",  
> > > > > > "precision": 3  
> > > > > > },  
> > > > > > "aggs": {  
> > > > > > "subbounds": {  
> > > > > > "geo\_bounds": {  
> > > > > > "field": "location"  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }'
> > > > > > 
> > > > > > On Thursday, 24 July 2014 07:46:31 UTC+1, svartalf wrote:
> > > > > > 
> > > > > > > Is there any way to use geo\_bounds as a sub aggregator?
> > > > > > > 
> > > > > > > I have a geohash\_grid aggregation, and it will be very useful to get  
> > > > > > > bounds for each bucket of the data.  
> > > > > > > Right now my ES 1.3.0 says that he "Could not find aggregator type  
> > > > > > > [bounds] in [aggregations]]".

--  
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/3fcdd090-5cb2-4a96-bdc3-740f94e63bb8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3fcdd090-5cb2-4a96-bdc3-740f94e63bb8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![owainb](https://avatars.discourse-cdn.com/v4/letter/o/e99b99/32.png) [@owainb](https://discuss.elastic.co/u/owainb)\
**Post date:** [September 3, 2014, 11:19am UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856/9 "2014-09-03T11:19:54Z")

</div>

I found the bug in array resizing code. Raised issue  
at [Aggregations: Geo bounds aggregation throwing ArrayIndexOutOfBoundsException on array resize · Issue #7556 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/7556).

On Tuesday, September 2, 2014 3:30:54 PM UTC+1, Colin Goodheart-Smithe  
wrote:

> Ok, yes this does look like a bug so if you could raise an issue on github  
> and post the issue link back in this thread, that would be great.
> 
> Thanks
> 
> Colin
> 
> On Tuesday, 2 September 2014 15:23:23 UTC+1, Owain Braddick wrote:
> 
> > Hi,
> > 
> > I hit exactly the same issue today. It seems that the problem occurs when  
> > the number of buckets in the outer geohash grid aggregation goes above a  
> > certain number (around 50 in my tests but that could be system dependent).  
> > The stack trace is below but doesn't tell much. If someone can confirm this  
> > is a bug I am happy to raise an issue.
> > 
> > [2014-09-02 14:46:54,698][DEBUG][action.search.type] [3-D Man]  
> > [typename][0], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> > execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
> > [true]  
> > org.elasticsearch.search.query.QueryPhaseExecutionException:  
> > [typename][0]:  
> > query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> > Query Failed [Failed to execute main query]  
> > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> > at  
> > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > at java.lang.Thread.run(Thread.java:744)  
> > Caused by: java.lang.ArrayIndexOutOfBoundsException  
> > [2014-09-02 14:46:54,699][DEBUG][action.search.type] [3-D Man]  
> > [typename][3], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> > execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
> > [true]  
> > org.elasticsearch.search.query.QueryPhaseExecutionException:  
> > [typename][3]:  
> > query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> > Query Failed [Failed to execute main query]  
> > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> > at  
> > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > at java.lang.Thread.run(Thread.java:744)  
> > Caused by: java.lang.ArrayIndexOutOfBoundsException  
> > [2014-09-02 14:46:54,707][DEBUG][action.search.type] [3-D Man]  
> > [typename][4], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> > execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
> > [true]  
> > org.elasticsearch.search.query.QueryPhaseExecutionException:  
> > [typename][4]:  
> > query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> > Query Failed [Failed to execute main query]  
> > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> > at  
> > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > at java.lang.Thread.run(Thread.java:744)  
> > Caused by: java.lang.ArrayIndexOutOfBoundsException  
> > [2014-09-02 14:46:54,708][DEBUG][action.search.type] [3-D Man]  
> > [typename][1], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> > execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
> > [true]  
> > org.elasticsearch.search.query.QueryPhaseExecutionException:  
> > [typename][1]:  
> > query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> > Query Failed [Failed to execute main query]  
> > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> > at  
> > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > at java.lang.Thread.run(Thread.java:744)  
> > Caused by: java.lang.ArrayIndexOutOfBoundsException  
> > [2014-09-02 14:46:54,713][DEBUG][action.search.type] [3-D Man]  
> > [typename][2], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> > execute [org.elasticsearch.action.search.SearchRequest@37a97844]  
> > org.elasticsearch.search.query.QueryPhaseExecutionException:  
> > [typename][2]:  
> > query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> > Query Failed [Failed to execute main query]  
> > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> > at  
> > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > at java.lang.Thread.run(Thread.java:744)  
> > Caused by: java.lang.ArrayIndexOutOfBoundsException  
> > [2014-09-02 14:46:54,714][DEBUG][action.search.type] [3-D Man] All  
> > shards failed for phase: [query]
> > 
> > On Friday, July 25, 2014 2:47:39 PM UTC+1, Colin Goodheart-Smithe wrote:
> > 
> > > Could you post the full stack trace from the elasticsearch log file?  
> > > This will help in working out where the query falls over
> > > 
> > > Thanks
> > > 
> > > On Friday, 25 July 2014 01:18:49 UTC+1, svartalf wrote:
> > > 
> > > > It is really odd, but it failed for me on the precision levels 6 and 7  
> > > > with a ArrayIndexOutOfBoundsException, and working for 5 and 8 levels.
> > > > 
> > > > I had put a big query examples here:  
> > > > [ElasticSearch geo\_bounds aggregation failure on precision levels 6 and 7 · GitHub](https://gist.github.com/svartalf/5db600e7ea2907fbda3a)
> > > > 
> > > > четверг, 24 июля 2014 г., 18:05:30 UTC+9 пользователь Colin  
> > > > Goodheart-Smithe написал:
> > > > 
> > > > > I think the problem is that you have an extra aggregations object  
> > > > > surrounding the geo\_bounds aggregation. Try the following:
> > > > > 
> > > > > curl -XGET "[http://localhost:9200/postings/\_search](http://localhost:9200/postings/_search)" -d'  
> > > > > {  
> > > > > "query": {  
> > > > > "filtered": {  
> > > > > "filter": {  
> > > > > "geo\_bounding\_box": {  
> > > > > "point": {  
> > > > > "bottom\_right": [  
> > > > > 104.45856200712711,  
> > > > > 52.208730692828844  
> > > > > ],  
> > > > > "top\_left": [  
> > > > > 104.19077025908017,  
> > > > > 52.34035674074375  
> > > > > ]  
> > > > > }  
> > > > > }  
> > > > > },  
> > > > > "query": {  
> > > > > "match\_all": {}  
> > > > > }  
> > > > > }  
> > > > > },  
> > > > > "aggregations": {  
> > > > > "cells": {  
> > > > > "geohash\_grid": {  
> > > > > "field": "point",  
> > > > > "precision": 6  
> > > > > },  
> > > > > "aggregations": {  
> > > > > "lat": {  
> > > > > "avg": {  
> > > > > "script": "doc["point"].lat"  
> > > > > }  
> > > > > },  
> > > > > "lon": {  
> > > > > "avg": {  
> > > > > "script": "doc["point"].lon"  
> > > > > }  
> > > > > },  
> > > > > "hits": {  
> > > > > "top\_hits": {  
> > > > > "\_source": {  
> > > > > "include": [  
> > > > > "short\_description"  
> > > > > ]  
> > > > > },  
> > > > > "size": 1  
> > > > > }  
> > > > > },  
> > > > > "bounds": {  
> > > > > "geo\_bounds": {  
> > > > > "field": "point"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > },  
> > > > > "size": 0  
> > > > > }'
> > > > > 
> > > > > On Thursday, 24 July 2014 09:32:10 UTC+1, svartalf wrote:
> > > > > 
> > > > > > Here is an example:  
> > > > > > [request.sh · GitHub](https://gist.github.com/svartalf/c3cb76c40dd4fa1374fa)
> > > > > > 
> > > > > > I'm using two inner aggregation functions, and with "top\_hits"  
> > > > > > removed, "geo\_bounds" works sometimes, and sometimes fails with a  
> > > > > > `response_2.json` (in the example) or `response_3.json`.  
> > > > > > With an enabled "top\_hits" aggregator it is also throwing  
> > > > > > `response_1.json` text.
> > > > > > 
> > > > > > I'm trying to group points into the buckets and annotate them with a  
> > > > > > top\_hit item and geo bounds for each bucket, and got stuck a little. Maybe  
> > > > > > I should move one of those two aggregations one level deeper?
> > > > > > 
> > > > > > четверг, 24 июля 2014 г., 16:52:01 UTC+9 пользователь Colin  
> > > > > > Goodheart-Smithe написал:
> > > > > > 
> > > > > > > You should be able to achieve this with the below query. If you  
> > > > > > > still cannot get it working could you provide a cURL example which  
> > > > > > > reproduces your issue?
> > > > > > > 
> > > > > > > curl -XGET "[http://localhost:9200/geo/\_search](http://localhost:9200/geo/_search)" -d'  
> > > > > > > {  
> > > > > > > "size": 0,  
> > > > > > > "aggs": {  
> > > > > > > "geohash" : {  
> > > > > > > "geohash\_grid": {  
> > > > > > > "field": "location",  
> > > > > > > "precision": 3  
> > > > > > > },  
> > > > > > > "aggs": {  
> > > > > > > "subbounds": {  
> > > > > > > "geo\_bounds": {  
> > > > > > > "field": "location"  
> > > > > > > }  
> > > > > > > }  
> > > > > > > }  
> > > > > > > }  
> > > > > > > }  
> > > > > > > }'
> > > > > > > 
> > > > > > > On Thursday, 24 July 2014 07:46:31 UTC+1, svartalf wrote:
> > > > > > > 
> > > > > > > > Is there any way to use geo\_bounds as a sub aggregator?
> > > > > > > > 
> > > > > > > > I have a geohash\_grid aggregation, and it will be very useful to  
> > > > > > > > get bounds for each bucket of the data.  
> > > > > > > > Right now my ES 1.3.0 says that he "Could not find aggregator type  
> > > > > > > > [bounds] in [aggregations]]".

--  
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/9e69e502-f8d3-49d4-be19-90673c1e118a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9e69e502-f8d3-49d4-be19-90673c1e118a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [September 3, 2014, 2:32pm UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856/10 "2014-09-03T14:32:44Z")

</div>

Thanks for finding the details of the bug and raising it. I have pushed a  
fix which should be available in the next release

On Wednesday, 3 September 2014 12:19:54 UTC+1, Owain Braddick wrote:

> I found the bug in array resizing code. Raised issue at  
> [Aggregations: Geo bounds aggregation throwing ArrayIndexOutOfBoundsException on array resize · Issue #7556 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/7556).
> 
> On Tuesday, September 2, 2014 3:30:54 PM UTC+1, Colin Goodheart-Smithe  
> wrote:
> 
> > Ok, yes this does look like a bug so if you could raise an issue on  
> > github and post the issue link back in this thread, that would be great.
> > 
> > Thanks
> > 
> > Colin
> > 
> > On Tuesday, 2 September 2014 15:23:23 UTC+1, Owain Braddick wrote:
> > 
> > > Hi,
> > > 
> > > I hit exactly the same issue today. It seems that the problem occurs  
> > > when the number of buckets in the outer geohash grid aggregation goes above  
> > > a certain number (around 50 in my tests but that could be system  
> > > dependent). The stack trace is below but doesn't tell much. If someone can  
> > > confirm this is a bug I am happy to raise an issue.
> > > 
> > > [2014-09-02 14:46:54,698][DEBUG][action.search.type] [3-D Man]  
> > > [typename][0], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> > > execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
> > > [true]  
> > > org.elasticsearch.search.query.QueryPhaseExecutionException:  
> > > [typename][0]:  
> > > query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> > > Query Failed [Failed to execute main query]  
> > > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> > > at  
> > > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > > at java.lang.Thread.run(Thread.java:744)  
> > > Caused by: java.lang.ArrayIndexOutOfBoundsException  
> > > [2014-09-02 14:46:54,699][DEBUG][action.search.type] [3-D Man]  
> > > [typename][3], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> > > execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
> > > [true]  
> > > org.elasticsearch.search.query.QueryPhaseExecutionException:  
> > > [typename][3]:  
> > > query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> > > Query Failed [Failed to execute main query]  
> > > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> > > at  
> > > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > > at java.lang.Thread.run(Thread.java:744)  
> > > Caused by: java.lang.ArrayIndexOutOfBoundsException  
> > > [2014-09-02 14:46:54,707][DEBUG][action.search.type] [3-D Man]  
> > > [typename][4], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> > > execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
> > > [true]  
> > > org.elasticsearch.search.query.QueryPhaseExecutionException:  
> > > [typename][4]:  
> > > query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> > > Query Failed [Failed to execute main query]  
> > > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> > > at  
> > > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > > at java.lang.Thread.run(Thread.java:744)  
> > > Caused by: java.lang.ArrayIndexOutOfBoundsException  
> > > [2014-09-02 14:46:54,708][DEBUG][action.search.type] [3-D Man]  
> > > [typename][1], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> > > execute [org.elasticsearch.action.search.SearchRequest@37a97844] lastShard  
> > > [true]  
> > > org.elasticsearch.search.query.QueryPhaseExecutionException:  
> > > [typename][1]:  
> > > query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> > > Query Failed [Failed to execute main query]  
> > > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> > > at  
> > > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > > at java.lang.Thread.run(Thread.java:744)  
> > > Caused by: java.lang.ArrayIndexOutOfBoundsException  
> > > [2014-09-02 14:46:54,713][DEBUG][action.search.type] [3-D Man]  
> > > [typename][2], node[sEDEsE4GQ2yqxVb5njslDQ], [P], s[STARTED]: Failed to  
> > > execute [org.elasticsearch.action.search.SearchRequest@37a97844]  
> > > org.elasticsearch.search.query.QueryPhaseExecutionException:  
> > > [typename][2]:  
> > > query[filtered(filtered(fieldname:other)-\>_:_)-\>cache(\_type:indexname)],from[0],size[10]:  
> > > Query Failed [Failed to execute main query]  
> > > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
> > > at  
> > > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> > > at  
> > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> > > at java.lang.Thread.run(Thread.java:744)  
> > > Caused by: java.lang.ArrayIndexOutOfBoundsException  
> > > [2014-09-02 14:46:54,714][DEBUG][action.search.type] [3-D Man]  
> > > All shards failed for phase: [query]
> > > 
> > > On Friday, July 25, 2014 2:47:39 PM UTC+1, Colin Goodheart-Smithe wrote:
> > > 
> > > > Could you post the full stack trace from the elasticsearch log file?  
> > > > This will help in working out where the query falls over
> > > > 
> > > > Thanks
> > > > 
> > > > On Friday, 25 July 2014 01:18:49 UTC+1, svartalf wrote:
> > > > 
> > > > > It is really odd, but it failed for me on the precision levels 6 and 7  
> > > > > with a ArrayIndexOutOfBoundsException, and working for 5 and 8 levels.
> > > > > 
> > > > > I had put a big query examples here:  
> > > > > [ElasticSearch geo\_bounds aggregation failure on precision levels 6 and 7 · GitHub](https://gist.github.com/svartalf/5db600e7ea2907fbda3a)
> > > > > 
> > > > > четверг, 24 июля 2014 г., 18:05:30 UTC+9 пользователь Colin  
> > > > > Goodheart-Smithe написал:
> > > > > 
> > > > > > I think the problem is that you have an extra aggregations object  
> > > > > > surrounding the geo\_bounds aggregation. Try the following:
> > > > > > 
> > > > > > curl -XGET "[http://localhost:9200/postings/\_search](http://localhost:9200/postings/_search)" -d'  
> > > > > > {  
> > > > > > "query": {  
> > > > > > "filtered": {  
> > > > > > "filter": {  
> > > > > > "geo\_bounding\_box": {  
> > > > > > "point": {  
> > > > > > "bottom\_right": [  
> > > > > > 104.45856200712711,  
> > > > > > 52.208730692828844  
> > > > > > ],  
> > > > > > "top\_left": [  
> > > > > > 104.19077025908017,  
> > > > > > 52.34035674074375  
> > > > > > ]  
> > > > > > }  
> > > > > > }  
> > > > > > },  
> > > > > > "query": {  
> > > > > > "match\_all": {}  
> > > > > > }  
> > > > > > }  
> > > > > > },  
> > > > > > "aggregations": {  
> > > > > > "cells": {  
> > > > > > "geohash\_grid": {  
> > > > > > "field": "point",  
> > > > > > "precision": 6  
> > > > > > },  
> > > > > > "aggregations": {  
> > > > > > "lat": {  
> > > > > > "avg": {  
> > > > > > "script": "doc["point"].lat"  
> > > > > > }  
> > > > > > },  
> > > > > > "lon": {  
> > > > > > "avg": {  
> > > > > > "script": "doc["point"].lon"  
> > > > > > }  
> > > > > > },  
> > > > > > "hits": {  
> > > > > > "top\_hits": {  
> > > > > > "\_source": {  
> > > > > > "include": [  
> > > > > > "short\_description"  
> > > > > > ]  
> > > > > > },  
> > > > > > "size": 1  
> > > > > > }  
> > > > > > },  
> > > > > > "bounds": {  
> > > > > > "geo\_bounds": {  
> > > > > > "field": "point"  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > },  
> > > > > > "size": 0  
> > > > > > }'
> > > > > > 
> > > > > > On Thursday, 24 July 2014 09:32:10 UTC+1, svartalf wrote:
> > > > > > 
> > > > > > > Here is an example:  
> > > > > > > [request.sh · GitHub](https://gist.github.com/svartalf/c3cb76c40dd4fa1374fa)
> > > > > > > 
> > > > > > > I'm using two inner aggregation functions, and with "top\_hits"  
> > > > > > > removed, "geo\_bounds" works sometimes, and sometimes fails with a  
> > > > > > > `response_2.json` (in the example) or `response_3.json`.  
> > > > > > > With an enabled "top\_hits" aggregator it is also throwing  
> > > > > > > `response_1.json` text.
> > > > > > > 
> > > > > > > I'm trying to group points into the buckets and annotate them with a  
> > > > > > > top\_hit item and geo bounds for each bucket, and got stuck a little. Maybe  
> > > > > > > I should move one of those two aggregations one level deeper?
> > > > > > > 
> > > > > > > четверг, 24 июля 2014 г., 16:52:01 UTC+9 пользователь Colin  
> > > > > > > Goodheart-Smithe написал:
> > > > > > > 
> > > > > > > > You should be able to achieve this with the below query. If you  
> > > > > > > > still cannot get it working could you provide a cURL example which  
> > > > > > > > reproduces your issue?
> > > > > > > > 
> > > > > > > > curl -XGET "[http://localhost:9200/geo/\_search](http://localhost:9200/geo/_search)" -d'  
> > > > > > > > {  
> > > > > > > > "size": 0,  
> > > > > > > > "aggs": {  
> > > > > > > > "geohash" : {  
> > > > > > > > "geohash\_grid": {  
> > > > > > > > "field": "location",  
> > > > > > > > "precision": 3  
> > > > > > > > },  
> > > > > > > > "aggs": {  
> > > > > > > > "subbounds": {  
> > > > > > > > "geo\_bounds": {  
> > > > > > > > "field": "location"  
> > > > > > > > }  
> > > > > > > > }  
> > > > > > > > }  
> > > > > > > > }  
> > > > > > > > }  
> > > > > > > > }'
> > > > > > > > 
> > > > > > > > On Thursday, 24 July 2014 07:46:31 UTC+1, svartalf wrote:
> > > > > > > > 
> > > > > > > > > Is there any way to use geo\_bounds as a sub aggregator?
> > > > > > > > > 
> > > > > > > > > I have a geohash\_grid aggregation, and it will be very useful to  
> > > > > > > > > get bounds for each bucket of the data.  
> > > > > > > > > Right now my ES 1.3.0 says that he "Could not find aggregator type  
> > > > > > > > > [bounds] in [aggregations]]".

--  
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/081244d9-febc-4b33-a66b-8e01044b5c0d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/081244d9-febc-4b33-a66b-8e01044b5c0d%40googlegroups.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, 1:04am UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-as-a-sub-aggregator/18856/11 "2017-07-06T01:04:39Z")

</div>


