【发布时间】:2014-12-22 03:19:08
【问题描述】:
我有一个弹性搜索运行这样的文档:
{
id: 1,
price: 620000,
propertyType: "HO",
location: {
lat: 51.41999,
lon: -0.14426
},
active: true,
rentOrSale: "S",
}
我正在尝试使用聚合来获取有关使用聚合的某个区域的统计信息,我正在使用的查询如下:
{
"sort": [
{
"id": "desc"
}
],
"query": {
"bool": {
"must": [
{
"term": {
"rentOrSale": "s"
}
},
{
"term": {
"active": true
}
}
]
},
"filtered": {
"filter": {
"and": [
{
"geo_distance": {
"distance": "15.0mi",
"location": {
"lat": 51.50735,
"lon": -0.12776
}
}
}
]
}
}
},
"aggs": {
"propertytype_agg": {
"terms": {
"field": "propertyType"
},
"aggs": {
"avg_price": {
"avg": {
"field": "price"
}
}
}
},
"bed_agg": {
"terms": {
"field": "numberOfBedrooms"
},
"aggs": {
"avg_price": {
"avg": {
"field": "price"
}
}
}
}
}
}
但在结果中我看不到聚合。只要我删除查询的布尔或过滤部分,我就可以看到聚合。我不知道为什么会这样,也不知道如何获得这些过滤器的聚合。我已经尝试使用question 的答案,但我无法解决它。有什么想法吗?
【问题讨论】:
标签: elasticsearch pyelasticsearch