es的日常使用

#### 前言

在liunx终端上,我们会经常对es进行查询与删除索引的操作,也是需要掌握的技能

 

#### 查询

##### 语法

> curl [xxx/--user elasticsearch_username:elasticsearch_password] -XGET xxx

 

##### 查看全部索引

> curl -XGET http://localhost:9200/_cat/indices  

 

##### 查看索引下的全部内容

> curl -XGET http://localhost:9200/_cat/logstash-dev-app-20200418/_search

 

##### 过滤索引存储大于GB的信息

> curl -XGET http://localhost:9200/_cat/indices | grep gb

 

#### 删除

##### 语法

> curl [xxx/--user elasticsearch_username:elasticsearch_password] -XDELETE xxx   

 

##### 删除一个索引

> curl -XDELETE http://localhost:9200/logstash-dev-app-20200418

 

##### 一次性删除多个索引

以相同的school-agent开头的索引,这样就可以不用一个一个的删除索引

> curl -XDELETE http://localhost:9200/school-agent*

 

##### 删除多个不同索引名的索引

> curl -XDELETE http://localhost:9200/school-server*,school-agent*

 

##### 使用通配符删除所有的索引

> curl -XDELETE http://localhost:9200/*    

or

> curl -XDELETE http://localhost:9200/_all

注释: 通常不建议使用通配符,误删了后果很严重,所有的index都会被删除,为了安全起见,可以在配置文件中设置禁用_all和*通配符

```

action.destructive_requires_name = rue

```

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值