Composite aggs with an after key in a large index take forever

I'm running into an issue where composite aggs with an after key seem to run forever on large indices (several 100m docs) when the same agg without an after key runs just fine.

So this runs in seconds:

{
  "size": 0, 
  "aggs": {
    "test": {
      "composite": {
        "sources": [{"test": {"terms": {"field": "field1"}}}],
        "size": 1
      }
    }
  }
}

But when using the after key returned from that query, it seems to run forever edit: did more testing and found that it did actually return after ~4.5 minutes

{
  "size": 0, 
  "aggs": {
    "test": {
      "composite": {
        "sources": [{"test": {"terms": {"field": "field1"}}}],
        "after": {"test": value1},
        "size": 1
      }
    }
  }
}

This issue doesn't seem to happen for smaller indices. Any ideas what could be causing this? Would greatly appreciate any help :pray:

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