【发布时间】:2019-12-20 08:44:55
【问题描述】:
我使用的是 Elasticsearch 6.8,但无法在单个查询中访问多个索引。我读过documentation 和以前的questions,但由于某种原因我无法弄清楚。
我认为设置是相当标准的。我有一个 filebeat 将日志推送到 elasticsearch 中。并没有真正适应标准配置,所以 filebeat 每天都在创建一个新索引。我可以很好地查询每个索引以获取一天的所有结果:
# works, returns data from filebeat-6.1.2-2019.12.20
curl -X GET "https://whatever:9200/filebeat-6.1.2-2019.12.20/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"wildcard" : {
"nginx.access.url" : "/something/*"
}
}
}
'
# works, returns data from filebeat-6.1.2-2019.12.19
curl -X GET "https://whatever:9200/filebeat-6.1.2-2019.12.19/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"wildcard" : {
"nginx.access.url" : "/something/*"
}
}
}
'
我现在尝试在一次查询中查询多个索引,以一次获取超过一天的数据,但我始终只从索引文件beat-6.1.2.-2019.12.19 获取数据,不管我做什么。
# comma-separated list of indeces, nope.
curl -X GET "https://whatever:9200/filebeat-6.1.2-2019.12.20,filebeat-6.1.2-2019.12.19/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"wildcard" : {
"nginx.access.url" : "/something/*"
}
}
}
'
# _all, nope.
curl -X GET "https://whatever:9200/_all/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"wildcard" : {
"nginx.access.url" : "/something/*"
}
}
}
'
# just not specifying an index, nope nope nope.
curl -X GET "https://whatever:9200/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"wildcard" : {
"nginx.access.url" : "/something/*"
}
}
}
'
因为这应该根据我找到的所有资源来工作,所以我觉得我错过了一些非常明显的东西。
FWIW,我来自 python 库elasticsearch-dsl,在那里我遇到了完全相同的问题,但我在这个例子中使用了 curl,因为它是最通用的事情。所以如果有人有这个方向的答案,这也将非常受欢迎。
【问题讨论】:
标签: elasticsearch filebeat elasticsearch-dsl elasticsearch-6