【发布时间】:2021-08-23 15:54:38
【问题描述】:
我有一个从代码运行的查询(使用外部库),现在我尝试使用 curl 命令直接从终端运行它:
这是原始查询:
{
"index": [
"logstash-*2021.08.21*",
"logstash-*2021.08.22*"
],
"ignore_unavailable": true,
"allow_no_indices": true,
"type": "doc",
"body": {
"query": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"gte": "now-24H/H"
}
}
}
]
}
}
}
}
但是从 Linux 终端运行以下查询:
curl -u "*******:****************" -XGET "https://XXXXXXXXXXXXXXXXXXXXXXXXXX:9200/logstash-
*/_search"
-H 'Content-Type: application/json'
-d '
{
"index": [
"logstash-*2021.08.21*",
"logstash-*2021.08.22*"
],
"ignore_unavailable": true,
"allow_no_indices": true,
"type": "doc",
"body": {
"query": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"gte": "now-24H/H"
}
}
}
]
}
}
}
}
'
返回错误:
{"error":{"root_cause":[{"type":"parsing_exception","reason":"未知 一个 START_ARRAY 的键 [index].","line":1,"col":10}],"type":"parsing_exception","reason":"未知 [index] 中 START_ARRAY 的键。","line":1,"col":10},"status":4
值得注意的是,在没有附加参数的情况下运行以下查询,会返回正确的结果:
curl -u "elastic:****************" -XGET "https://XXXXXXXXXXXXXXXXXXXXXXXXXX:9200/logstash-*/_search"
我需要在终端查询中更改什么?
【问题讨论】:
标签: elasticsearch