# List sorted nested objects from multiple documents

**URL:** <https://discuss.elastic.co/t/list-sorted-nested-objects-from-multiple-documents/191986>\
**Category:** Elasticsearch\
**Created:** [July 24, 2019, 8:47am UTC](https://discuss.elastic.co/t/list-sorted-nested-objects-from-multiple-documents/191986 "2019-07-24T08:47:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![creaticious](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/creaticious/32/24784_2.png) [@creaticious](https://discuss.elastic.co/u/creaticious)\
**Post date:** [July 24, 2019, 8:47am UTC](https://discuss.elastic.co/t/list-sorted-nested-objects-from-multiple-documents/191986/1 "2019-07-24T08:47:14Z")

</div>

Hey guys,

i want to know if it is possible to return a list of nested objects, sorted by a nested field but include parent fields...something like an inverted document...

Imagine a product list with nested "date"-objects:

```
PUT products/basics/1
{
    "sku" : "12345",
    "title" : "test product",
    "image" : "test_high.jpg",
    "productmanager": "none",
    "dates":[
      {
        "date-origin": "01.01.2018",
        "date-destination": "10.01.2018",
        "instock": 1
      },
      {
        "date-origin": "20.01.2018",
        "date-destination": "30.01.2018",
        "instock": 0
      }
    ]
}

PUT products/basics/2
{
    "sku" : "6789",
    "title" : "test product 2",
    "image" : "blah.jpg",
    "productmanager": "someone",
    "dates":[
      {
        "date-origin": "03.01.2018",
        "date-destination": "04.01.2018",
        "instock": 1
      },
      {
        "date-origin": "25.01.2018",
        "date-destination": "30.01.2018",
        "instock": 0
      }
    ]
}

```

Now i would like to have a list of dates with the product information...sorted by date...like

```
[
    	{
    		"date-origin": "01.01.2018",
    		"image": "test_high.jpg",
    		"sku": 12345
    	},
    	{
    		"date-origin": "03.01.2018",
    		"image": "blah.jpg",
    		"sku": 6789
    	},
    	{
    		"date-origin": "20.01.2018",
    		"image": "test_high.jpg",
    		"sku": 12345
    	},
    	{
    		"date-origin": "25.01.2018",
    		"image": "blah.jpg",
    		"sku": 6789
    	}
]

```

Is there a way to do this in elastic?

Thank you!

---

<div class="post-metadata">

**Author:** ![creaticious](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/creaticious/32/24784_2.png) [@creaticious](https://discuss.elastic.co/u/creaticious)\
**Post date:** [July 30, 2019, 10:02am UTC](https://discuss.elastic.co/t/list-sorted-nested-objects-from-multiple-documents/191986/2 "2019-07-30T10:02:27Z")

</div>

no one???

---

<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:** [August 27, 2019, 10:16am UTC](https://discuss.elastic.co/t/list-sorted-nested-objects-from-multiple-documents/191986/3 "2019-08-27T10:16:00Z")

</div>

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