Help on getting query to count avg, min and max nestings

I have an index with one nested field. Some docs have 10 nested docs and a few may have thousands of nested docs.
I want to find the average/min and max count of nested items count across the index.

Sample data: in this ReferenceList is a nested object. for docid=1, ReferenceList has 3 entires. In docid=2, ReferenceList has 1 entry.
I am looking for some stats like
min=1 , max =3 , Average=2

{
  {
  "docid": "1",
    "ReferenceList": [
      {
        "pos": 1,
        "txt": "data"
      },
      {
        "pos": 2,
        "txt": "data"
      },
      {
        "pos": 3,
        "txt": "data"
      }
    ]
  },
  {
   "docid": "2",
    "ReferenceList": [
      {
        "pos": 1,
        "txt": "termd"
      }
    ]
  }
}

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