文档计数大于 'x'、geo_point 聚合 elasticsearch

Document count greater than 'x', geo_point aggregations elasticsearch

我目前正在执行以下查询,以在弹性搜索中以一定精度聚合所有点。

{
  "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
                  }
                }
}

我需要获取所有计数大于特定数字的桶。我该怎么做?

您可以添加字段

GET _search
{
    "query": {
        "range" : {
            "age" : {
                "gte" : 5000,
            }
        }
    }
}

如文档中所述: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html

已解决,我使用了以下过滤器:

{
    "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"
          }
        }
      }
    }
  }
}