How to use 'Terms' query to return value in my search order?

My doc:

{"local_id" : 1654,
"universal_id" : 5412896
}
{
"local_id" : 1657,
"universal_id" : 9658742
}
{
"local_id" : 1658,
"universal_id" : 6325412
}

My query :

{"from": 0, "size": 10,"query": {
"bool": {
"must" : [{ 
"terms": { 
"universal_id": [ 6325412, 5412896, 5412896] 
}}]}}}

My Actual result:

 "hits" : [
      {
        "_source" : {
          "local_id" : 1654,
          "universal_id" : 5412896
        }
      },
      {
        "_source" : {
          "local_id" : 1658,
          "universal_id" : 6325412
        }
      }
    ]

But I need result as below in my querying order ,

My Expected result:

{ 
       "_source" : {
         "local_id" : 1658,
         "universal_id" : 6325412
       }
     },
     {
       "_source" : {
         "local_id" : 1658,
         "universal_id" : 6325412
       }
     },
 {
       "_source" : {
         "local_id" : 1654,
         "universal_id" : 5412896
       }
     }
   ]

How to achieve this in elasticsearch?

Afaik, there is no way to return value in your search order. Why do you need to sort value in your search order?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.