** I am trying to aggregate and find price ranges if on the basis of nested offer price array (nested Array) object of sellerInfoES. Internal field is "offerPrice". How I can write aggregation on the nested array field in Elasticsearch. I tried this following query, but it's not working. Getting this error: Parse Failure [Found two aggregation type definitions in [price_ranges]: [nested] and [filter]]
Mapping:
{
"productsearch": {
"mappings": {
"product": {
"properties": {
"brand": {
"type": "string"
},
"categories": {
"type": "string"
},
"model": {
"type": "string"
},
"mrp": {
"type": "double"
},
"productName": {
"type": "string"
},
"rating": {
"type": "double"
},
"reviewCount": {
"type": "long"
},
"sellerInfoES": {
"type": "nested",
"properties": {
"addr": {
"type": "string"
},
"country": {
"type": "string"
},
"geoAddress": {
"type": "string"
},
"location": {
"type": "string"
},
"offerPrice": {
"type": "double"
},
"pinCode": {
"type": "string"
},
"sellerId": {
"type": "long"
},
"sellerLocation": {
"type": "geo_point"
},
"state": {
"type": "string"
}
}
},
"sku": {
"type": "long"
},
"subCategory": {
"type": "string"
}
}
}
}
}
}
Query:
{
"price_ranges": {
"nested": {
"path": "sellerInfoES"
},
"aggs": {
"range": {
"field": "offerPrice",
"ranges": [
{
"gte": 1000
},
{
"gte": 1000,
"lte": 10000
},
{
"gte": 10000,
"lte": 25000
},
{
"gte": 25000
}
]
}
}
}
}