<p dir="auto">Hi,<br>
I'm noticing the reverse nested aggregation feature is available only for the nested data model but not for parent-child. We need to use parent-child since update latency is very important to us but noticing that aggregations which are several levels deep are not possible in a single query using parent child.</p>
<p dir="auto">Here is how this can be done with the Nested model. Is this something which can be added for parent-child?</p>
<p dir="auto">REQUEST:-<br>
POST/document_test/document/_search?search_type=count{<br>
"aggs": {<br>
"created_date_agg": {<br>
"nested": {<br>
"path": "metadata"<br>
},<br>
"aggs": {<br>
"created_date_agg_filter": {<br>
"filter": {<br>
"term": {<br>
"fieldid": "CREATEDDATE"<br>
}<br>
},<br>
"aggs": {<br>
"created_date_agg_values": {<br>
"terms": {<br>
"field": "fieldvalue"<br>
},<br>
"aggs": {<br>
"metadata_to_parent": {<br>
"reverse_nested": {</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="                                },
                                &quot;aggs&quot;: {
                                    &quot;filetype_agg&quot;: {
                                        &quot;nested&quot;: {
                                            &quot;path&quot;: &quot;metadata&quot;
                                        },
                                        &quot;aggs&quot;: {
                                            &quot;filetype_agg_filter&quot;: {
                                                &quot;filter&quot;: {
                                                    &quot;term&quot;: {
                                                        &quot;fieldid&quot;: &quot;DOCTYPE&quot;
                                                    }
                                                },
                                                &quot;aggs&quot;: {
                                                    &quot;filetype_agg_values&quot;: {
                                                        &quot;terms&quot;: {
                                                            &quot;field&quot;: &quot;fieldvalue&quot;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}"><pre class="notranslate"><code class="notranslate">                                },
                                "aggs": {
                                    "filetype_agg": {
                                        "nested": {
                                            "path": "metadata"
                                        },
                                        "aggs": {
                                            "filetype_agg_filter": {
                                                "filter": {
                                                    "term": {
                                                        "fieldid": "DOCTYPE"
                                                    }
                                                },
                                                "aggs": {
                                                    "filetype_agg_values": {
                                                        "terms": {
                                                            "field": "fieldvalue"
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
</code></pre></div>
<p dir="auto">}</p>
<p dir="auto">RESPONSE:-<br>
RESPONSE: -"aggregations": {<br>
"created_date_agg": {<br>
"doc_count": 12,<br>
"created_date_agg_filter": {<br>
"doc_count": 4,<br>
"created_date_agg_values": {<br>
"doc_count_error_upper_bound": 0,<br>
"sum_other_doc_count": 0,<br>
"buckets": [<br>
{<br>
"key": "6/9/2015",<br>
"doc_count": 3,<br>
"metadata_to_parent": {<br>
"doc_count": 3,<br>
"filetype_agg": {<br>
"doc_count": 9,<br>
"filetype_agg_filter": {<br>
"doc_count": 3,<br>
"filetype_agg_values": {<br>
"doc_count_error_upper_bound": 0,<br>
"sum_other_doc_count": 0,<br>
"buckets": [<br>
{<br>
"key": "Excel",<br>
"doc_count": 2<br>
},<br>
{<br>
"key": "Microsoft Word",<br>
"doc_count": 1<br>
}<br>
]<br>
}<br>
}<br>
}<br>
}<br>
},<br>
{<br>
"key": "6/10/2015",<br>
"doc_count": 1,<br>
"metadata_to_parent": {<br>
"doc_count": 1,<br>
"filetype_agg": {<br>
"doc_count": 3,<br>
"filetype_agg_filter": {<br>
"doc_count": 1,<br>
"filetype_agg_values": {<br>
"doc_count_error_upper_bound": 0,<br>
"sum_other_doc_count": 0,<br>
"buckets": [<br>
{<br>
"key": "Powerpoint",<br>
"doc_count": 1<br>
}<br>
]<br>
}<br>
}<br>
}<br>
}<br>
}<br>
]<br>
}<br>
}<br>
}<br>
}<br>
}</p>
<p dir="auto">I get these NPE after running after running for about 10 minutes or less.   I did not see these NPEs with ES v1.4.1.</p>
<p dir="auto">ES v1.4.2 on tribe node and the ES clusters the tribe node is aggregating.</p>
<p dir="auto">[2015-01-06 04:08:01,591][WARN ][tribe                    ] [dc1-app1111] failed to process [cluster event from mobile_dc1, zen-disco-receive(from master [[dc1-app2222][TLF_56CDTV2dHXmUf0XFUg][dc1-app2222][inet[/172.24.23.163:9300]]{max_local_storage_nodes=1, master=true, zone=data}])]<br>
java.lang.NullPointerException<br>
at org.elasticsearch.cluster.routing.RoutingTable$Builder.add(RoutingTable.java:429)<br>
at org.elasticsearch.tribe.TribeService$TribeClusterStateListener$1.execute(TribeService.java:265)<br>
at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:329)<br>
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:153)<br>
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)<br>
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)<br>
at java.lang.Thread.run(Thread.java:745)</p>
<p dir="auto">Here is tribe config:</p>
<p dir="auto">tribe:<br>
mobile_dc1:<br>
cluster.name: mobile-es_dc1<br>
discovery.zen.ping.unicast.hosts: ["dc1-app2222", "dc1-app3333"]<br>
mobile_dc2:<br>
cluster.name: mobile-es_dc2<br>
discovery.zen.ping.unicast.hosts: ["dc2-app2222", "dc2-app3333"]<br>
mobile_dc3:<br>
cluster.name: mobile-es_dc3<br>
discovery.zen.ping.unicast.hosts: ["dc3-app2222", "dc3-app3333"]<br>
feed_dc1:<br>
cluster.name: dc1-logstash<br>
discovery.zen.ping.unicast.hosts: ["dc1-app1234", "dc1-app1235"]<br>
feed_dc2:<br>
cluster.name: dc2-logstash<br>
discovery.zen.ping.unicast.hosts: ["dc2-app2345", "dc2-app2346"]</p>