Multiple self nesting

I want to store hierarchical data into elasticsearch, for example:

root
folder1
file11
file12
folder2
file21
file22

I made it so every item has parent who is pointing on self type. For
example:
curl -XPOST localhost:9200/filesystem
and then:
curl -XPOST localhost:9200/filesystem/document/_mapping -d '
{
"document": {
"_parent": { "type": "document"}
}
}'

Test data are:
curl -XPOST localhost:9200/filesystem/document/1?parent=null -d '
{
"name": "root"
}'

curl -XPOST localhost:9200/filesystem/document/2?parent=1 -d '
{
"name": "folder1"
}'

curl -XPOST localhost:9200/filesystem/document/3?parent=2 -d '
{
"name": "file11"
}'

curl -XPOST localhost:9200/filesystem/document/4?parent=2 -d '
{
"name": "file12"
}'

curl -XPOST localhost:9200/filesystem/document/5?parent=1 -d '
{
"name": "folder2"
}'

curl -XPOST localhost:9200/filesystem/document/6?parent=5 -d '
{
"name": "file21"
}'

curl -XPOST localhost:9200/filesystem/document/7?parent=5 -d '
{
"name": "file22"
}'

I wonder is it possible to get some document with all childs. For example I
want to get root folder with all subfolders and files.
If I simply try to search like this:
curl -XPOST localhost:9200/filesystem/document/_search -d '{
"query": {
"term": { "name": "root"}
}
}'

result is:
{"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},
"hits":{"total":1,"max_score":0.30685282,"hits":[{"_index":"filesystem",
"_type":"document","_id":"1","_score":0.30685282, "_source" :
{
"name": "root"
}}]}}

But what I want is something like:
...
..., "_source":
{
"name": "root",
"child_documents": [
{
"name": "folder1",
"child_documents": [
{
"name": "file11"
},
{
"name": "file12"
}
]
},
{
"name": "folder2",
"child_documents": [
{
"name": "file21"
},
{
"name": "file22"
}
]
}
]
}

Is it even possible in elasticsearch?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.