Hi Everyone,
I like to use elasticsearch aggregations to achive my task but problem is that my document contains nested object and i want to apply aggregations on nested object. so please help me in it. please find the below sample data and my requirement
I have documents like below:
[
{
"name": "Item 1",
"resellers": [
{
"reseller": "companyA",
"price": 450
},
{
"reseller": "companyB",
"price": 400
}
]
},
{
"name": "Item 2",
"resellers": [
{
"reseller": "companyA",
"price": 350
},
{
"reseller": "companyB",
"price": 400
}
]
},
{
"name": "Item 3",
"resellers": [
{
"reseller": "companyA",
"price": 450
},
{
"reseller": "companyB",
"price": 400
}
]
}
]
I need the average price of each document like
[
{
"name": "Item 1",
"Average": 425
},
{
"name": "Item 2",
"Average": 375
},
{
"name": "Item 3",
"Average": 425
}
]