# Top hits agg - hits (parent and child) sorted by geolocation

**URL:** <https://discuss.elastic.co/t/top-hits-agg-hits-parent-and-child-sorted-by-geolocation/21853>\
**Category:** Elasticsearch\
**Created:** [January 27, 2015, 6:12pm UTC](https://discuss.elastic.co/t/top-hits-agg-hits-parent-and-child-sorted-by-geolocation/21853 "2015-01-27T18:12:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cody\_Stringham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cody_stringham/32/944_2.png) [@Cody\_Stringham](https://discuss.elastic.co/u/Cody_Stringham)\
**Post date:** [January 27, 2015, 6:12pm UTC](https://discuss.elastic.co/t/top-hits-agg-hits-parent-and-child-sorted-by-geolocation/21853/1 "2015-01-27T18:12:26Z")

</div>

Hey everyone,

We have been implementing ES for our API for a few months, and have finally  
come to a wall with the top hits aggregation.

We are trying to use this to get similar items grouped under a parent. The  
aggregation is working perfectly, except when we want to add a geolocation  
sort. We have done a little bit with the script sorting based on another  
field **{ max: {script: "doc['offer\_value'].value"} }** we just cant seem  
to do this based on the geolocation distance.

Any advice would be extremely appreciated, thank you in advance!

Cody

--  
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/fa836997-036c-4b07-af19-837dcf3f2916%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fa836997-036c-4b07-af19-837dcf3f2916%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Cody\_Stringham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cody_stringham/32/944_2.png) [@Cody\_Stringham](https://discuss.elastic.co/u/Cody_Stringham)\
**Post date:** [January 30, 2015, 5:31pm UTC](https://discuss.elastic.co/t/top-hits-agg-hits-parent-and-child-sorted-by-geolocation/21853/2 "2015-01-30T17:31:57Z")

</div>

Just not possible in a single request, eh?

On Tuesday, January 27, 2015 at 11:12:26 AM UTC-7, Cody Stringham wrote:

> Hey everyone,
> 
> We have been implementing ES for our API for a few months, and have  
> finally come to a wall with the top hits aggregation.
> 
> We are trying to use this to get similar items grouped under a parent. The  
> aggregation is working perfectly, except when we want to add a geolocation  
> sort. We have done a little bit with the script sorting based on another  
> field **{ max: {script: "doc['offer\_value'].value"} }** we just cant seem  
> to do this based on the geolocation distance.
> 
> Any advice would be extremely appreciated, thank you in advance!
> 
> Cody

--  
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/bc221a99-cb84-4d9c-9254-c338ea21a2ed%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bc221a99-cb84-4d9c-9254-c338ea21a2ed%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, 12:35am UTC](https://discuss.elastic.co/t/top-hits-agg-hits-parent-and-child-sorted-by-geolocation/21853/3 "2017-07-06T00:35:35Z")

</div>


