Update counter by bucket?

I have an agg query that combines documents with the same email in buckets. I am trying to implement a counter that increments an ID by bucket - but the records within each bucket should have the same ID. I have seen the update API documentation but that doesnt address bucket updates.

https://www.elastic.co/guide/en/elasticsearch/reference/7.2/docs-update-by-query.html

please see query below

POST /my_index/_search? 
{ 
    "size": 0, 
    "aggs": { 
        "GroupByType": { 
            "terms": { 
                "field": "Email.keyword", 
                "size": 15 
            }, 
            "aggs": { 
                "Group": { 
                    "top_hits": { 
                        "size": 2, 
                        "_source": { 
                            "includes": [ 
                                "Email", 
                                "CustomerNo", 
                                "FirstName", 
                                "LastName", 
                                "Phone" 
                            ] 
                        }, 
                        "sort": [ 
                            { 
                                "CustomerNo.keyword": { 
                                    "order": "asc" 
                                } 
                            } 
                        ] 
                    } 
                } 
            } 
        } 
    } 
}

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