I’m using Opensearch to retrieve some documents from my index. Here is the query I’m using:
GET /your_index/_search
{
"size": 3,
"sort": [
{ "ts_id": "desc" }
],
"query": {
"bool": {
"filter": [
{ "term": { "myid": "your_value" } },
{
"range": {
"ts_id": {
"from": 12345567788,
"include_lower": true,
"include_upper": true,
"to": null
}
}
}
],
"must": {
"bool": {
"should": [
{ "term": { "type": 12 } }
]
}
}
}
}
}
myid: “keyword”
ts_id: “long”
type: “keyword”
result has wrong order:
eg:
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 9,
"relation": "eq"
},
"max_score": null,
"hits": [
{... "ts_id": 346},
{... "ts_id": 344},
{... "ts_id": 345},
]
Can anyone help me understand why this might be happening and how I can ensure the results are returned in the correct order?