Aggregation 504 bad gateway

When I use script to do aggregation and want to find two documents with the same fields in es, 504 bad gateway.
Maybe it is caused by too much data. Is there any solution?
I used partition.

{
  "size": 0,
  "aggs": {
    "duplicateCount": {
      "terms": {
        "script": {
          "source":"doc['id'].value ",
          "lang": "painless"
        },
        "min_doc_count": 2,
        "size": 10,
        "include": {
          "partition": 0,
          "num_partitions": 10
        }
      },
      "aggs": {
        "duplicateDocuments": {
          "top_hits": {
            "size": 10
          }
        }
      }
    }
  }
}

error

<html>
    <head>
        <title>504 Gateway Time-out</title>
    </head>
    <body>
        <center>
            <h1>504 Gateway Time-out</h1>
        </center>
        <hr>
        <center>nginx</center>
    </body>
</html>

Sounds like an error message from nginx not elasticsearch.

Thank you very much.

Nginx error is caused by a timeout.
How can I make this request return a partial result quickly?

May be have a look at https://www.elastic.co/guide/en/elasticsearch/reference/7.x/async-search-intro.html or increase the nginx timeout?

Why are you using a painless script to run a terms aggregation? Why not a terms agg on the id field?

Thank you very much. I'm just giving a simple example here. In our real use scenario, the type is an array. It is more complicated to sort each value in the array for aggregation, so script is used.

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