I want to sort my root based on field in its child. I have tried many approach but didn't work.
"hits" : {
"total" : 232268,
"max_score" : 1.0,
"hits" : [
{
"_index" : "providers",
"_type" : "_doc",
"_id" : "1003915141",
"_score" : 1.0,
"_source" : {
"middleName" : "J",
"facilities" : [
{
"cost" : 50.92
}
]
}
},
{
"_index" : "providers",
"_type" : "_doc",
"_id" : "1003915620",
"_score" : 1.0,
"_source" : {
"middleName" : "A.",
"facilities" : [
{
"cost" : 5823.024
},
{
"cost" : 5894.875
},
{
"cost" : 248.405
}
]
}
},
{
"_index" : "providers",
"_type" : "_doc",
"_id" : "1003917147 ",
"_score" : 1.0,
"_source" : {
"middleName" : "L",
"facilities" : [
{
"cost" : 65.58
}
]
}
},
{
"_index" : "providers",
"_type" : "_doc",
"_id" : "1003923335",
"_score" : 1.0,
"_source" : {
"middleName" : "S.",
"facilities" : [
{
"cost" : 4744.932
},
{
"cost" : 198.399
}
]
}
},
{
"_index" : "providers",
"_type" : "_doc",
"_id" : "1003925074",
"_score" : 1.0,
"_source" : {
"middleName" : "",
"facilities" : [
{
"cost" : 11652.64
},
{
"cost" : 15453.483
},
{
"cost" : 1233.04
}
]
}
},
{
"_index" : "providers",
"_type" : "_doc",
"_id" : "1003925355",
"_score" : 1.0,
"_source" : {
"middleName" : "",
"facilities" : [
{
"cost" : 63.328
}
]
}
},
{
"_index" : "providers",
"_type" : "_doc",
"_id" : "1003927633",
"_score" : 1.0,
"_source" : {
"middleName" : "D",
"facilities" : [
{
"cost" : 6737.7
}
]
}
},
{
"_index" : "providers",
"_type" : "_doc",
"_id" : "1003935925",
"_score" : 1.0,
"_source" : {
"middleName" : "MICHELLE",
"facilities" : [
{
"cost" : 60.429
},
{
"cost" : 53.511
}
]
}
},
{
"_index" : "providers",
"_type" : "_doc",
"_id" : "1003942061",
"_score" : 1.0,
"_source" : {
"middleName" : "",
"facilities" : [
{
"cost" : 7986.907
}
]
}
},
{
"_index" : "providers",
"_type" : "_doc",
"_id" : "1003963265",
"_score" : 1.0,
"_source" : {
"middleName" : "LAURETA",
"facilities" : [
{
"cost" : 55.788
}
]
}
}
]
}
I want to sort my roots based on cost in nested facilities. I tried this. But couldn't do it with the code below.
"sort": [
{
"facilities.cost": {
"order": "asc"
}
}
]