What is the most optimal way to get documents by _id?

I have a cluster with 7 nodes out of which 3 are master nodes. Elasticsearch version is 5.5. I need to fetch documents in bulk by the ids. I'm using the terms query like this

GET my_index/my_type/_search
{
  "query": {
    "terms": {
      "_id": [
        "123",
        "456"
      ]
    }
  }
}

I am passing around 200-250 ids to this query. It's taking around 3-4 seconds to fetch the documents. The index has around 90 million documents. Any ways to fetch the documents faster?

Have you tried the mget API?

Yes, I've tried _mget API, but did not see much improvements.

Then I am not aware of any faster way.

This is very, very old and has been EOL a long time so I would recommend that you upgrade to the latest version.

1 Like

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