在 elasticsearch 中使用 mserch 查询排除索引名称

Exclude index name using mserch query in elasticsearch

我正在使用 elasticsearch 为多个索引使用 msearch API 来获取日志。 但我需要排除一些索引。假设我有 a、b、c、d、e 索引,但我不想包含索引 b、c。

我写了 elasticsearch 查询来获取记录:

GET _msearch?
{"index":"*","size":100000,"exclude":["b","c"]}  //used kibana to check indexes
{"query":{}}  //required to successfully run the query

但我得到的记录包括索引 b、c。我检查了文档,但没有为此获得任何适当的资源。 我该如何解决这个问题??

这段代码应该可以解决问题:

GET _msearch?
{"index":"*,-b,-c","size":100000}
{"query":{}} 

注意 "index" 值中的减号 (-)。

虽然_msearch docs page, it looks like most of the APIs supporting multi index execution work in the same way中没有明确提及:

Most APIs that refer to an index parameter support execution across multiple indices, using simple test1,test2,test3 notation (or _all for all indices). It also support wildcards, for example: test* or test or tet or test, and the ability to "exclude" (-), for example: test*,-test3.

一般情况下, 会搜索多个索引。