I have the following data model (just an example) stored in one index:
- object { id: 1, parent: null, title: ....}
- object { id: 2, parent: 1, title: ....}
- object { id: 3, parent: 1, title: ....}
- ...
Now, suppose I want to do a query listing all the objects having parent= null (root objects) and for each of these root objects I want the children object as children in the json response, e.g.
object {
id: 1, parent: null, title: ... ,
childrens [
object { id: 2, parent: 1, title: ....},
object { id: 3, parent: 1, title: ....}
]
Is it possible?
I simplified a lot the use case, but I have a lot of attributes for each object and most of the time I do query on single object only. Only for this use case I show, I would not like to replicate the tree structure in a separate index, because I should duplicate a lot of data.
Thanks!