What's the performance difference between `ids query` and `terms query`?

Say we got a large id set, then which query would be the best choice?

# ids query
{
  "query": {
    "bool": {
      "filter": [
        {
          "ids" : {
            "values" : ["1", "2", ....,"100000"]
          }
        }
      ]
    }
  }
}

# terms query
{
  "query": {
    "bool": {
      "filter": [
        {
          "terms" : {
            "_id" : ["1", "2", ....,"100000"]
          }
        }
      ]
    }
  }
}

# terms lookup query
{
  "query": {
    "bool": {
      "filter": [
        {
          "terms" : {
            "_id" : {
              "index": "user",
              "type": "user",
              "id": "12345",
              "path": "followers"
            }
          }
        }
      ]
    }
  }
}

As far as I know there is not much difference as queries with lots of terms are quite expensive and can be slow.

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