I have example data as below, But I need to aggregate teams and players with multiple nested fields ("foot-ball-teams", "cricket-teams").
I have to get output unique teams from "foot-ball-teams", "cricket-teams" and unique team's players of each team
PUT /sports/
{
"mappings": {
"_doc": {
"properties": {
"foot-ball-teams": {
"type": "nested",
"properties": {
"name": {
"type": "keyword"
},
"players": {
"type": "keyword"
}
}
},
"cricket-teams": {
"type": "nested",
"properties": {
"name": {
"type": "keyword"
},
"players": {
"type": "keyword"
}
}
}
}
}
}
}
POST /sports/_doc
{
"foot-ball-teams": [
{ "name": "team1",
"players": [
"player1",
"player2"
]
},
{ "name": "team2",
"players": [
"player1",
"player3"
]
}
],
"cricket-teams": [
{ "name": "team1",
"players": [
"player1",
"player2"
]
},
{ "name": "team2",
"players": [
"player1",
"player4"
]
}
]
}