gpt4 book ai didi

mysql - 如何在我的 elasticsearch 查询中附加时间戳范围?

转载 作者:行者123 更新时间:2023-11-29 11:15:50 25 4
gpt4 key购买 nike

我正在尝试将 elasticsearch 查询作为 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 中,以便从索引获取数据在一个日期范围内。我尝试在查询末尾添加为:

和时间戳:[2015-05-27T00:00:00.128Z+TO+2015-05-27T23:59:59.128Z]"

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

最佳答案

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

AND timestamp:[2015-05-27T00:00:00.128Z TO 2015-05-27T23:59:59.128Z]"
^ ^
| |
remove these

关于mysql - 如何在我的 elasticsearch 查询中附加时间戳范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39789160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com