目前,我正在执行以下查询,以便在弹性搜索中在一定精度范围内聚合所有点。
{
"aggs": {
"coordinates": {
"geohash_grid": {
"field": "properties.Geometry.geo_point",
"precision": 12
},
"aggs": {
"centroid": {
"geo_centroid": {
"field": "properties.Geometry.geo_point"
}
}
}
}
}
}他们的反应是
"aggregations": {
"coordinates": {
"buckets": [
{
"key": "s00000000000",
"doc_count": 82571,
"centroid": {
"location": {
"lat": 0,
"lon": 0
},
"count": 82571
}
},
{
"key": "6gyf4bf8m0uh",
"doc_count": 58587,
"centroid": {
"location": {
"lat": -23.55052001774311,
"lon": -46.633309721946716
},
"count": 58587
}
},
{
"key": "7h2y8hz76g8m",
"doc_count": 14551,
"centroid": {
"location": {
"lat": -19.924501832574606,
"lon": -43.93523778766394
},
"count": 14551
}
}
}我需要得到所有的桶,有一个计数大于一定的数目。我怎么能这么做?
发布于 2018-04-18 13:58:04
解决后,我使用了以下过滤器:
{
"aggs": {
"coordinates": {
"geohash_grid": {
"field": "properties.Geometry.geo_point",
"precision": 12
},
"aggs": {
"sales_bucket_filter": {
"bucket_selector": {
"buckets_path": {
"doc_count": "centroid.count"
},
"script": "params.doc_count > 500"
}
},
"centroid": {
"geo_centroid": {
"field": "properties.Geometry.geo_point"
}
}
}
}
}
}发布于 2018-04-18 13:31:31
您可以添加字段。
GET _search
{
"query": {
"range" : {
"age" : {
"gte" : 5000,
}
}
}
}如文档中描述的那样:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html
https://stackoverflow.com/questions/49900607
复制相似问题