Reputation: 995
I have a relationship in my elasticsearch in which A is a parent and B is a child of A and than C is a child of B.
A->B->C.
At the time of insertion the relationship was the same B have A as parent and in the insertion of grandchild B was the parent.
Now when I wanted to get all the grandchild using the following query its returning None.
{
"query": {
"has_parent": {
"parent_type": "A",
"query": {
"has_parent": {
"parent_type": "B",
"query": {
"match_all": {}
}
}
}
}
}
}
What is the issue ? Is it something I am missing when storing any help is appreciated.
Upvotes: 0
Views: 173
Reputation: 995
I have achieved it using the following query.
{
"query": {
"has_parent": {
"parent_type": "B",
"query": {
"has_parent": {
"parent_type": "A",
"query": {
"match_all": {}
}
}
}
}
}
}
It was basically the parent should be nested instead child.
Upvotes: 1