Search for a parent and all it's children in one query in elastic search Search for a parent and all it's children in one query in elastic search elasticsearch elasticsearch

Search for a parent and all it's children in one query in elastic search


This worked for me. The only drawback is that kibana Discover dashboard does not support has_child or has_parent and so we cannot build visualizations.

POST test_index/_search{    "query": {        "bool": {            "must": [{                "has_child": {                    "type": "childname",                    "query": {                        "match": {                            "properties.name": "hello"                        }                    },                     "inner_hits": {}                    }            },            {                "match": {                    "account.name": "random",                    "version": {"2.0"}                }            },{                "match": {                    "account.name": "random",                    "version": {"2.0"}                }            ]        }    }}