有什么方法可以在弹性搜索中使用cat API排除特定索引?

时间:2019-03-28 12:38:25

标签: elasticsearch curl

我正在编写一个需要备份的shell脚本。问题在于参数应为cURL请求,而随URL传递的参数应忽略特定索引。我阅读了ES cat API文档,但无法弄清楚,其他答案给出了grep作为解决方案。

健康状况指数 绿色打开abcd 绿色开放 绿色开放ijkl 绿色开放式mnop 绿色打开qrst

已执行的命令是: curl -X GET“ http://hostname:port/_cat/indices/ *,-efgh” curl -s http://hostname:port/_cat/indices | grep -v“ efgh”

我想忽略efgh,而其余索引应打印出来。帮助将不胜感激

错误:{“错误”:{“ root_cause”:[{“类型”:“ index_not_found_exception”,“原因”:“无此类索引”,“ resource.type”:“ index_or_alias”,“ resource.id” :“ efgh”,“ index_uuid”:“ na ”,“ index”:“ efgh”}]],“ type”:“ index_not_found_exception”,“ reason”:“无此索引”,“资源.type“:” index_or_alias“,” resource.id“:” efgh“,” index_uuid“:” na “,” index“:” efgh“},”状态“:404}

2 个答案:

答案 0 :(得分:0)

您可以使用以下语法:

GET _cat/indices/*,-efgh

意思是“包括所有内容,但efgh

在卷曲时,它会给出以下信息:

curl -s -XGET 'hostname:post/_cat/indices/*,-efgh*'

答案 1 :(得分:0)

GET /%2Bindex1,-index2 / type1,type2 / _search?q =编程

看看:

Including and excluding indexes in Elasticsearch query