Query get documents by giving an array of document ids same order of array

Hi,

I am a beginner with Elasticsearch and my application is using it for monitoring and search engine.I am currently using ES 5.6.4.

I would like to know if it's possible to get documents by giving an array of documents ids to my ES Query and get it in the same order of the array. If that's possible, what would be the syntax?

I have an example here, the goal is to get these documents in the same order as the list:

GET connect-dev/_search
{
  "query": { 
    "bool": { 
      "filter": 
        { "terms": { "_id" : ["elitevideos-367",
            "elitevideos-41",
            "elitevideos-42",
            "elitevideos-39",
            "elitevideos-38",
            "elitevideos-11",
            "elitetrainings-526",
            "elitetrainings-527",
            "elitetrainings-528",
            "eliteinfographies-397",
            "elitetrainings-490",
            "elitetrainings-491",
            "elitetrainings-492",
            "comments-155064",
            "comments-8791",
            "posts-12440",
            "comments-183049",
            "comments-132821",
            "comments-25532",
            "comments-239393"] }}
    }
  },
  "size": 20,
  "from": 0
}

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