Hi,
I'm trying to sort the fields present within an array which is of type nested.
My data :
{
"name" : "abc",
"shipping":[
{
"shipmentcode" : 5,
"shipmentstatus" : "resolved",
"shipmentorderid": "12345"
},
{
"shipmentcode" : 4,
"shipmentstatus" : "delivered",
"shipmentorderid": "12345"
},
{
"shipmentcode" : 1,
"shipmentstatus" : "orderconfirmed",
"shipmentorderid": "12345"
},
{
"shipmentcode" : 2,
"shipmentstatus" : "RTF",
"shipmentorderid": "12345"
},
{
"shipmentcode" : 3,
"shipmentstatus" : "shipped","shipmentorderid": "12345"
}
]
}
In here, I have to run a query a term query to find the docs that matches name to "abc" and in that result I have to sort the shipping array based on the "shipmentcode"..something like the below when sorter in desc order-
"shipping" : [
{
"shipmentcode" : 5,
"shipmentstatus" : "resolved",
"shipmentorderid" : "12345"
},
{
"shipmentcode" : 4,
"shipmentstatus" : "delivered",
"shipmentorderid" : "12345"
},
{
"shipmentcode" : 3,
"shipmentstatus" : "shipped",
"shipmentorderid" : "12345"
},
{
"shipmentcode" : 2,
"shipmentstatus" : "RTF",
"shipmentorderid" : "12345"
},
{
"shipmentcode" : 1,
"shipmentstatus" : "orderconfirmed",
"shipmentorderid" : "12345"
}
]
Is this even possible in elasticsearch? I have to sort on the result!!