# Sort nested fields cross parent documents

**URL:** <https://discuss.elastic.co/t/sort-nested-fields-cross-parent-documents/206799>\
**Category:** Elasticsearch\
**Created:** [November 6, 2019, 1:37pm UTC](https://discuss.elastic.co/t/sort-nested-fields-cross-parent-documents/206799 "2019-11-06T13:37:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![permagne](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@permagne](https://discuss.elastic.co/u/permagne)\
**Post date:** [November 6, 2019, 1:37pm UTC](https://discuss.elastic.co/t/sort-nested-fields-cross-parent-documents/206799/1 "2019-11-06T13:37:25Z")

</div>

Hi,  
We have a model that looks something like this:

```
Order: {
properties: {
	...
	shipments: {
		type: "nested",
		properties: {
			...
			deliveryDate: {
				type: "date"
			},
		}

	}
}

```

}

We need to be able to search all orders with a given criterias and return a list of shipments sorted by date. The problem we are facing is that an order may have multiple shipments with different delivery dates. If we fetch all orders and then sort the shipments, it would work, but that does not work very well when we have a huge amount of orders.  
Any ideas?  
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:** [December 4, 2019, 1:37pm UTC](https://discuss.elastic.co/t/sort-nested-fields-cross-parent-documents/206799/2 "2019-12-04T13:37:29Z")

</div>

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