0

我有一个包含一些文档的数据集。每个文档都有很多字段,其中三个让我感兴趣的是“时间”和“纬度”和“经度”

如果纬度在 -90 到 90 之间,经度在 -180 到 180 之间,并且它们不是同时为零,则我们说文档中的位置是有效的。

我想编写一个查询,按时间分组,间隔为一小时,显示每个间隔我们有多少每种类型的文档。

我写了这个

{
  "size": 0,
  "aggs": 
  {
    "docs_per_hour": 
    {
      "date_histogram": 
      {
        "field": "time",
        "interval": "hour",
        "format": "yyyy-MM-dd hh:mm:ss"
      }
    }
  }
}

当我运行它时,它会打印一些东西,比如

{
  "key_as_string" : "2020-04-19 01:00:00",
  "key" : 1587258000000,
  "doc_count" : 14
}

而不是 doc_count,我想要 doc_with_location_count 和 doc_without_location_count。

我如何编写该聚合

4

0 回答 0