Elasticsearch如何使用geohex_grid或geohash_grid返回一个完整的细节(或至少在doc_count:1时获得完整的细节)

zwghvu4y  于 2023-11-17  发布在  ElasticSearch
关注(0)|答案(1)|浏览(167)

Elasticsearch如何使用geohex_grid或geohash_grid返回一个完整的细节(或至少在doc_count:1时获得完整的细节)
我已经使用了elasticsearch geohex,但我能得到的是“key”和“doc_count”有没有办法得到完整的细节(或者在doc_count = 1的情况下)
belove是一个示例请求:

POST vt_data_warehouse/_search?size=0
{
  "aggregations": {
    "tiles_in_bounds": {
      "geohash_grid": {
        "field": "position",
        "precision": 6,
        "bounds": {
          "top_left": "POINT (104.731344 11.541166)",
          "bottom_right": "POINT (104.89368038286129 11.464655721322128)"
        }
      }
    }
  }
}

字符串
这就是结果:

"aggregations": {
    "tiles_in_bounds": {
      "buckets": [
        {
          "key": "",
          "doc_count": 32
        },
        {
          "key": "",
          "doc_count": 30
        },
        {
          "key": "",
          "doc_count": 21
        },
        {
          "key": "",
          "doc_count": 8
        },
        {
          "key": "",
          "doc_count": 7
        },
        {
          "key": "",
          "doc_count": 2
        },
        {
          "key": "",
          "doc_count": 1
        },
        {
          "key": "",
          "doc_count": 1
        },
        {
          "key": "",
          "doc_count": 1
        },
        {
          "key": "",
          "doc_count": 1
        },
        {
          "key": "",
          "doc_count": 1
        }
      ]
    }

tkclm6bt

tkclm6bt1#

为了显示每个存储桶中的文档,您可以简单地添加一个top_hits子聚合,如下所示:

POST vt_data_warehouse/_search?size=0
{
  "aggregations": {
    "tiles_in_bounds": {
      "geohash_grid": {
        "field": "position",
        "precision": 6,
        "bounds": {
          "top_left": "POINT (104.731344 11.541166)",
          "bottom_right": "POINT (104.89368038286129 11.464655721322128)"
        }
      },
      "aggs": {
        "details": {
          "top_hits": {
            "size": 50
          }
        }
      }
    }
  }
}

字符串

相关问题