Hi,
Say this is my document and Book Meta is a nested field
{
{
"Book ID": 1,
"Book Meta":
[
{
"Chapter_ID" : 1,
"Chapter_Gist": "<some-text-here>",
"Chapter_Tag": "tag-1"
},
{
"Chapter_ID" : 2,
"Chapter_Gist": "<some-text-here>",
"Chapter_Tag": "tag-2"
}
]
},
{
"Book ID": 2,
"Book Meta":
[
{
"Chapter_ID" : 1,
"Chapter_Gist": "<some-text-here>",
"Chapter_Tag": "tag-2"
},
{
"Chapter_ID" : 2,
"Chapter_Gist": "<some-text-here>",
"Chapter_Tag": "tag-3"
},
{
"Chapter_ID" : 3,
"Chapter_Gist": "<some-text-here>",
"Chapter_Tag": "tag-1"
}
]
}
}
In the above I need aggregations as follows:
{tag-1, tag-2} appear in book-1 and book-2, but other 2 cooccurrences {tag-1, tag-3}, {tag-2, tag-3} appear only in book-2, so the aggregation should give me
tag-1, tag-2 : 2
tag-2, tag-3 : 1
tag-1, tag-3 : 1
Does combination of include_in_parent to get a flat field in parent and use painless script to concatenate those values and then count work OR is there any other way to do this. Any help would be great