【发布时间】:2016-05-02 22:02:20
【问题描述】:
** 如果基于 SellerInfoES 的嵌套报价数组(嵌套数组)对象,我正在尝试聚合并查找价格范围。内部字段是“offerPrice”。如何在 Elasticsearch 中的嵌套数组字段上编写聚合。我尝试了以下查询,但它不起作用。出现此错误:解析失败 [在 [price_ranges] 中找到两个聚合类型定义:[nested] 和 [filter]]
映射:
{
"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"
}
}
}
}
}
}
查询:
{
"price_ranges": {
"nested": {
"path": "sellerInfoES"
},
"aggs": {
"range": {
"field": "offerPrice",
"ranges": [
{
"gte": 1000
},
{
"gte": 1000,
"lte": 10000
},
{
"gte": 10000,
"lte": 25000
},
{
"gte": 25000
}
]
}
}
}
}
【问题讨论】:
标签: elasticsearch spring-data-elasticsearch