# Sorting details

**URL:** https://discuss.elastic.co/t/sorting-details/15307
**Category:** Elasticsearch
**Created:** [January 18, 2014, 11:09am UTC](https://discuss.elastic.co/t/sorting-details/15307 "2014-01-18T11:09:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ahmed\_Sabaa](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@Ahmed\_Sabaa](https://discuss.elastic.co/u/Ahmed_Sabaa)
#### Post date: [January 18, 2014, 11:09am UTC](https://discuss.elastic.co/t/sorting-details/15307/1 "2014-01-18T11:09:47Z")

</div>

Hello,

I am trying to sort a document using the locations attribute of a  
subdocument with the following architecture.

{  
attribute1: value1,  
attribute2: value2,  
attribute3: [{  
attribute1: value1,  
location: {  
lat: latitude,  
lon: longitude  
}  
}, {  
attribute1: value1,  
location: {  
lat: latitude,  
lon: longitude  
}  
}]  
}, {  
attribute1: value1,  
attribute2: value2,  
attribute3: [{  
attribute1: value1,  
location: {  
lat: latitude,  
lon: longitude  
}  
}, {  
attribute1: value1,  
location: {  
lat: latitude,  
lon: longitude  
}  
}]  
}

So basically I have the location attribute indexed as a geo\_point in the  
mappings and I'm sorting the parent documents based on these values.  
Strangely enough, it works just fine without any alterations to the  
search/sort code but the problem is that I want to get which sub document  
(inside the array) resulted in having it's parent document as the first (or  
second or third) result so to have that as only sub document in the array.

I don't know if that's doable via elasticsearch directly (probably not) but  
is there anyway to get some details about the sorting itself at run time to  
do it at application level?

Regards,  
Ahmed.

--  
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/1d6bcf30-79f3-4ef7-9df9-e868806e2a5c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1d6bcf30-79f3-4ef7-9df9-e868806e2a5c%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:56am UTC](https://discuss.elastic.co/t/sorting-details/15307/2 "2017-07-06T01:56:03Z")

</div>


