PUT /my-index-000001/_doc/1?refresh
{
"product": "chocolate",
"salesManager" :["a","z","r"]
}
PUT /my-index-000001/_doc/2?refresh
{
"product": "chocolate",
"salesManager" :["v","f","d"]
}
PUT /my-index-000001/_doc/3?refresh
{
"product": "chocolate",
"salesManager" :["z","a","a"]
}
POST /my-index-000001/_search
{
"sort": {
"_script": {
"type": "String",
"script": {
"lang": "painless",
"source": "if(doc['salesManager'].size()>0) { return doc['salesManager'][0].toLowerCase()} return 'z';",
"params": {
"factor": 1.1
}
},
"order": "asc"
}
}
}
I need to sort asc the index data using salesManager 0th index sort
so the correct sort order is on doc id is 1->2->3
but I am getting 3->2->1