Parent aggregation based on child terms

Hello,

I have following parent child mapping (https://www.elastic.co/guide/en/elasticsearch/guide/current/parent-child-mapping.html).

PUT /site
{
    "mappings": {
        "blog": {
            "properties" : { "visited": { "type": "long" }
            },
            "comment": {
                "_parent": {
                    "type": "blog",
                    "properties" : { "tag": { "type": "string" } }
                }
            }
        }
    }
}

I want to sum "visited" in parent document "blog" for every unique values of "tag" in child document "comment".

{
    "size": 0,
        "query": {
            { "match_all" : {  } }
        },
        "aggs": {
            "by_tags": {
                "children": {
                    "type": "comment"
                },
                "terms": { "field": "tag" }
                "aggs": {
                    "visited": { "sum": { "field": "visited" } }
                }
            }
        }
}

It is not working. Am I doing something wrong, or it is not possible?

Thanks,
-Soumitra.

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