So, I finally figured out how to get buckets for the children documents, using this:
"aggs": {
"to-children": {
"children": {
"type": "folder"
},
"aggs": {
"the-filter": {
"filters": {
"filters": {
"2828": { "term": { "folder.folder_id_fi": 2828 } },
"2829": { "term": { "folder.folder_id_fi": 2829 } },
"2830": { "term": { "folder.folder_id_fi": 2830 } }
}
},
"aggs": {
"metrics" : {
"sum": {
"field": "file_size_2_fi"
}
}
}
}
}
}
}
But, the sum isn't working properly, it just contains 0 all the time, typical it seems when a field name isn't found. I'm guessing it's because I'm at the child (folder) level, and the file_size_2_fi field is in the parent document.
Any ideas on how to get this working?
As an side note, I find a LOT of questions about parent/children relationships and aggregations, and almost all of them have no answers (here and SO also), I'm thinking that the support for parent/child is pretty limited and I'm probably trying to do things that are too complicated?
The issue is our folder choices can change more rapidly than anything else, and it also needs to be very quick when clicked on the front end. Knowing that the whole document needs to be reindexed when a field changes, it seemed a good choice to move the folder information into a child document, speeding up changes to the folder information.
CraigL