I have daily indices named like request_response-yyyy-mm-dd
. When I execute the below query
curl -X GET "localhost:9200/request_response-*/_search?stored_fields=value&pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"term": {
"_id": {
"value": "092d882489ea6dc4a6d2dc16d97fb72192b17ca97eaaca59961e97597b6ba80c"
}
}
}
}
'
It returns result like below
{
"took" : 11,
"timed_out" : false,
"_shards" : {
"total" : 2,
"successful" : 2,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "request_response-2024-05-09",
"_type" : "_doc",
"_id" : "092d882489ea6dc4a6d2dc16d97fb72192b17ca97eaaca59961e97597b6ba80c",
"_score" : 1.0,
"fields" : {
"value" : [
"U29tZSBiaW5hcnkgYmxvYg=="
]
}
},
{
"_index" : "request_response-2024-05-10",
"_type" : "_doc",
"_id" : "092d882489ea6dc4a6d2dc16d97fb72192b17ca97eaaca59961e97597b6ba80c",
"_score" : 1.0,
"fields" : {
"value" : [
"U29tZSBiaW5hcnkgYmxvYg=="
]
}
}
]
}
}
Can someone let me know if there is a way I can get the hits sorted on the recent index name? I want the document from the recent index to come first.
I can sort the result on the client side after getting the response but here I am asking if it is possible to do on the opensearch side itself?