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

**URL:** https://discuss.elastic.co/t/query-get-documents-by-giving-an-array-of-document-ids-same-order-of-array/325172
**Category:** Kibana
**Tags:** eql-elastic-query-language
**Created:** [February 9, 2023, 4:14pm UTC](https://discuss.elastic.co/t/query-get-documents-by-giving-an-array-of-document-ids-same-order-of-array/325172 "2023-02-09T16:14:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Guillaume23](https://avatars.discourse-cdn.com/v4/letter/g/59ef9b/32.png) [@Guillaume23](https://discuss.elastic.co/u/Guillaume23)
#### Post date: [February 9, 2023, 4:14pm UTC](https://discuss.elastic.co/t/query-get-documents-by-giving-an-array-of-document-ids-same-order-of-array/325172/1 "2023-02-09T16:14:42Z")

</div>

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:

```auto
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
}

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 9, 2023, 4:15pm UTC](https://discuss.elastic.co/t/query-get-documents-by-giving-an-array-of-document-ids-same-order-of-array/325172/2 "2023-03-09T16:15:33Z")

</div>

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