我的查询
我正在写一个 Elasticsearch查询并在 URL 中指定请求的 index
并在外部 JSON 文件中指定查询:
curl
curl -s \
-u $user:$pass \
https://example.com:9243/index_name/search
-d @query.json
查询.json
{
"size": 5,
"from": 0,
"sort": [
{
"@timestamp": {
"order": "desc",
"unmapped_type": "boolean"
}
}
],
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "source:*.log",
"analyze_wildcard": true
}
}
]
}
},
"_source": {
"include": ["message", "@timestamp"],
"exclude": "_*"
}
}
我的问题
我想在查询文件中声明索引名称,而不是 URL。
我尝试了什么
- 将
index
或_index
字段添加到query.json
的不同位置 - 正在添加
"terms": { "_index": "filebeat*" }
to thequery
object
我的问题
在
中指定索引的正确方法是什么最佳答案
看indices query ,在那里你会看到你可以在 json 查询中设置索引。
如果您有任何问题,请告诉我。
关于json - 在负载中指定 elasticsearch 索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46632069/