Thank-you Adrien, I managed to do a terms child aggregation on Locations and am averaging out the geohashes in the browser.
The js code is here: Query: https://github.com/GlobAllomeTree/GlobAllomeTree/blob/elasticutils/globallometree/apps/allometric_equations/static/allometric_equations/js/map.js#L289 Parsing geohashes https://github.com/GlobAllomeTree/GlobAllomeTree/blob/elasticutils/globallometree/apps/allometric_equations/static/allometric_equations/js/map.js#L352 It seems to work very well and is still speedy. Kind regards, Tom On Thursday, May 1, 2014 10:59:59 PM UTC-7, Adrien Grand wrote: > > Hi, > > Unfortunately, accessing the parent bucket key is not possible. > > > On Fri, May 2, 2014 at 12:04 AM, Thomas Gruner > <[email protected]<javascript:> > > wrote: > >> Hello! >> >> I have been progressing well with aggregations, but this one has got me >> stumped. >> >> I'm trying to figure out how to access the key of the parent bucket from >> a child aggregation. >> >> The parent bucket is geohash_grid, and the child aggregation is avg >> (trying to get avg lat and lon, but only for points that match the parent's >> bucket's geohash key) >> >> Something like this: >> "aggregations" : { >> "LocationsGrid": { >> "geohash_grid" : { >> "field" : "Locations", >> "precision" : 7, >> }, >> "aggregations" : { >> "avg_lat": { >> "avg": { >> "script": "if >> (doc['Locations'].value.geohash.startsWith(*parent_bucket.key*)) >> doc['Locations'].value.lat;" >> } >> } >> }, >> } >> } >> >> >> Thanks for any help or ideas with this! >> >> -- >> 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 [email protected] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elasticsearch/624d0bdd-c380-4c72-b642-e6afff3458a9%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/624d0bdd-c380-4c72-b642-e6afff3458a9%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ba85de25-ca5e-41ba-988f-8449624525d1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
