Getting 504 on using aggs

Hi,

I am a new ES user, I type the following query, I get back results:

POST /test_index/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "id": "123456"
          }
        }
      ]
    }
  }
}

However, when I add a aggs criteria:

POST /test_index/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "id": "123456"
          }
        }
      ]
    }
  },
  "aggs": {
    "totalByCat": {
      "terms": {
        "field": "aggField"
      }
    }
  }
}

I get 504 Gateway Time-out.

Can anyone please help on how I can debug and fix the issue?

Can you post the entire error you are getting?