Hi All
I have a document like the following:
{
"applicant" : {
"firstName" : "tasd",
"lastName" : "asdfasdf"
},
"employmentsHistory" : [
{
"companyName" : "asdfa 1",
"isCurrentlyWorking" : false,
"startDate" : "2014-02-26",
"endDate" : "2016-01-20"
},
{
"companyName" : "asdfa 1",
"isCurrentlyWorking" : false,
"startDate" : "2018-02-26",
"endDate" : "2020-01-20"
},
{
"companyName" : "asdfa 1",
"isCurrentlyWorking" : false,
"startDate" : "2016-02-16",
"endDate" : "2018-01-18"
}
]
}
I want to get the doc. The nested object employmentsHistory should be sorted on the endDate field when returned. i.e
Should return:
{
"applicant" : {
"firstName" : "tasd",
"lastName" : "asdfasdf"
},
"employmentsHistory" : [
{
"companyName" : "asdfa 1",
"isCurrentlyWorking" : false,
"startDate" : "2014-02-26",
"endDate" : "2016-01-20"
},
{
"companyName" : "asdfa 1",
"isCurrentlyWorking" : false,
"startDate" : "2016-02-16",
"endDate" : "2018-01-18"
},
{
"companyName" : "asdfa 1",
"isCurrentlyWorking" : false,
"startDate" : "2018-02-26",
"endDate" : "2020-01-20"
}
]
}
I have tried multiple approaches for sorting. Seems, those sort gets applied on the parent documents. The inner hits query approach returns data on separate scope also. Will be glad if anyone helps me out? Thanks.