# Sorting based on a a field in nested level

**URL:** <https://discuss.elastic.co/t/sorting-based-on-a-a-field-in-nested-level/169101>\
**Category:** Elasticsearch\
**Created:** [February 19, 2019, 7:40pm UTC](https://discuss.elastic.co/t/sorting-based-on-a-a-field-in-nested-level/169101 "2019-02-19T19:40:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![athir.gillani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/athir.gillani/32/47708_2.png) [@athir.gillani](https://discuss.elastic.co/u/athir.gillani)\
**Post date:** [February 19, 2019, 7:40pm UTC](https://discuss.elastic.co/t/sorting-based-on-a-a-field-in-nested-level/169101/1 "2019-02-19T19:40:04Z")

</div>

I want to sort based on a calculated field at nested level.

For example, I have item buckets, each bucket has items which has different prices, I have attained a result which has list of buckets and inside bucket, I have sorted items on minimum price. I am able to run a inner hit to reorder items based on min price, I also want to sort buckets in the result set on minimum price, please suggest how can I do so.

But when I perform sort on document level, I am not able to fetch inner hit sorted items, hence not able to sort based on those. Is there a possibility to access sorted items in inner hits, or a way to assign a score at document level based on price value.

Thanks.

---

<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:** [March 19, 2019, 7:40pm UTC](https://discuss.elastic.co/t/sorting-based-on-a-a-field-in-nested-level/169101/2 "2019-03-19T19:40:12Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
