Nested Query summation aggregation for a subset received in the source

Hello everyone, I am trying for a an aggregated summation query on a nested object on the basis of a variable inside it and the summation on another variable present inside it. Till now I have been able to segregate the source on the basis of few terms.

Query

GET testing_index/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "testMeta.testCategory": "TEST"
          }
        }
      ]
    }
  },
  "_source": ["testingDetails.nestedDataItems.category","testingDetails.nestedDataItems.totalCount"]
}

Output:

"_source" : {
          "testingDetails" : {
            "nestedDataItems" : [
              {
                "category" : "ABC",
                "totalCount" : 447
              },
              {
                "category" : "XYZ",
                "totalCount" : 83
              }
            ]
          }
        }
      }

So the aggregation I need to implement is to add the totalCount for various documents according to the category

Solved. If anyone faces similar issues then you may refer to this: Bucket aggregations | Elasticsearch Guide [7.12] | Elastic

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