Postet this question on stackoverflow as well, but hoping to get better answers here.
I am trying to get all children and all parents of a doc id, where one child can be the parent, grandparent, grand grandparent etc. of multiple docs.
So let's say I have a structur like this (borrowed from https://www.elastic.co/guide/en/elasticsearch/reference/5.6/parent-join.html):
(parent)
question
/ \
/ \
comment answer
(child) (child)
In code:
PUT my_index
{
"settings": {
"mapping.single_type": true
},
"mappings": {
"doc": {
"properties": {
"my_join_field": {
"type": "join",
"relations": {
"question": ["answer", "comment"]
}
}
}
}
}
}
However, one can answer comments and comment answers theoretically forever. So say I have a question, that is structured like this:
(id: 1)
question
/ \
/ \
answer answer
(id: 5) (id: 8)
/ \ |
/ \ |
comment answer answer
(id: 15) (id: 12) (id: 9)
/ \ | / \
/ \ | / \
answer answer comment answer answer
(id: 16)(id: 17) (id: 19) (id: 10)(id: 11)
How do I get all the documents (ids 1, 5, 8, 9, 10, 11, 12, 15, 16, 17, 19), only knowing id 9?