elasticsearch 平均结果的弹性Luence查询,elasticsearch,lucene,elasticsearch,Lucene" /> elasticsearch 平均结果的弹性Luence查询,elasticsearch,lucene,elasticsearch,Lucene" />

elasticsearch 平均结果的弹性Luence查询

elasticsearch 平均结果的弹性Luence查询,elasticsearch,lucene,elasticsearch,Lucene,我不熟悉弹性搜索和Lucene语法 我想知道的是,在特定的时间段内,是否存在平均值 例如,我的索引中存储了以下信息 Index Name Result TimeStamp a-3 A 7 March 7th 2018, 16:17:35.000 a-3 A 13 March 7th 2018, 16:17:36.000 a-3 B 5 March 7th 2018, 16:17:37.000 我想写一个查询,返回16:17:35到16:

我不熟悉弹性搜索和Lucene语法

我想知道的是,在特定的时间段内,是否存在平均值

例如,我的索引中存储了以下信息

Index Name Result TimeStamp
a-3    A    7     March 7th 2018, 16:17:35.000
a-3    A    13    March 7th 2018, 16:17:36.000
a-3    B    5     March 7th 2018, 16:17:37.000
我想写一个查询,返回16:17:35到16:17:38之间的a=10和B=5的平均结果

这可能吗

谢谢。

您可以组合并使用嵌套聚合(和)

结果将如下所示

{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 3,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "name": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": [
        {
          "key": "A",
          "doc_count": 2,
          "stats": {
            "value": 10
          }
        },
        {
          "key": "B",
          "doc_count": 1,
          "stats": {
            "value": 5
          }
        }
      ]
    }
  }
}

谢谢,这就是我要找的。我是否可以转换成这个lucene查询语法,以便在kibana搜索栏或grafana中使用它?
{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 3,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "name": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": [
        {
          "key": "A",
          "doc_count": 2,
          "stats": {
            "value": 10
          }
        },
        {
          "key": "B",
          "doc_count": 1,
          "stats": {
            "value": 5
          }
        }
      ]
    }
  }
}