List sorted nested objects from multiple documents

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!

no one???

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