This question has been asked a few times in this community but have not got a response so hopefully someone reads this and helps me out!
I'm trying to do a composite aggregation on documents which have nested fields. Specifically I want one of the nested fields to be part of the composite bucket.
My documents are related to musical charts where each document is a specific song on a specific chart for a specific date and look similar to the example below
{
"provider": "Billboard",
"start_date": "2023-03-23",
"title": "Shake it Off",
"artist": "Taylor Swift",
"position": 1,
"credits":
[
{ "name": "Jack Antonoff", "role": "Producer"},
{ "name": "Max Martin", "role": "Songwriter"},
]
}
I want to be able to create a composite bucket aggregation including provider, title, artist, credits.name and credits.role. There is then a metric subaggregation for MIN(position) i.e. the best chart position each of the credited people achieved for a given song on a given chart.
The query below works but as soon as I add the nested field I get no hits.
{
"aggs": {
"my_buckets": {
"composite": {
"size": 1000,
"sources": [
{ "title": { "terms": { "field": "title"}}},
{ "artist": { "terms": { "field": "artist"}}},
{ "provider": { "terms": { "field": "provider"}}},
]
},
"aggregations": {
"peak_position": { "min": { "field": "position" }
}
}
}
}
}
Thanks!
Michael