Average Aggregation over two fields

What I would like to achieve is, given this type of docs:

    {
      "my_index": {
        "mappings": {
          "result": {
            "dynamic": "false",
            "_all": {
              "enabled": false
            },
            "properties": {
              "finales": {
                "properties": {
                  "attempts": {
                    "type": "integer"
                  },
                  "reattempts": {
                    "type": "integer"
                  }
                }
              }
          }
        }
      }
    }

is a query with an aggregation to calculate a reattempts rate:

avg(reattempts/attempts)

I've tried several options, but I'm not able to do it for two fields.

So, for each document I need to calculate de rate reattempts/attempts, and over this apply the average.

What I've achieved so far is to calculate avg(reattempts)/avg(attempts), but that's not what I exactly need.