0

我正在尝试执行弹性搜索查询作为POST请求,以便从我创建的索引中提取数据。索引中的数据是来自 MySQL DB 的表,但已配置logstash

这是我的要求和JSON正文:

http://localhost:9200/response_summary/_search

身体:

{
   "query": {
       "query_string": {
           "query": "transactionoperationstatus:\"charged\" AND api:\"payment\" AND operatorid:\"XL\" AND userid:*test AND time:\"2015-05-27*\" AND responsecode:(200+201)"
       }
   },
    "aggs": {
      "total": {
          "terms": {
              "field": "userid"
          },
   "aggs": {
      "total": {
          "sum": {
              "script": "Double.parseDouble(doc['chargeamount'].value)"
          }
        }
    }
  }
 }
}

在上面的JSON正文中,我需要将 附加timestamp到 中query_string,以便从日期范围内的索引中获取数据。我尝试在查询末尾添加:

AND timestamp:[2015-05-27T00:00:00.128Z+TO+2015-05-27T23:59:59.128Z]"

我哪里错了?任何帮助,将不胜感激。

4

1 回答 1

1

您只需要删除它们,+因为它们仅在通过 URL 查询字符串发送查询时才需要(即对空格进行 URL 编码),但如果您使用query_string查询,则不需要这样做

AND timestamp:[2015-05-27T00:00:00.128Z TO 2015-05-27T23:59:59.128Z]"
                                       ^  ^
                                       |  |
                                   remove these
于 2016-09-30T10:32:06.387 回答