大数据技术之elasticsearch基础操作

//curl命令http请求方式
curl -X PUT "http://10.20.1.1/elastic" \
    -H 'Content-Type: application/json;charset=utf-8' \
    -u elastic:iie123456
    -d @mapping.json
创建或更新资源:PUT(替换)、POST(创建)
删除资源:DELETE
查看资源:GET、HEAD(只返回http头部信息,不返回正文内容)

1、新建索引

curl -XPUT  -H 'Content-Type: application/json'  -u 'elastic:111111' 'http://127.0.0.1:9200/estest' -d@test.json

其中test.json是这样的

{ "mappings": { "properties": { "title": { "type": "text" }, "content": { "type": "text" }, "date": { "type": "date" } } } }

2、删除索引

curl -XDELETE -u 'elastic:111111' 'http://$HOSTNAME:9200/estest*'

3、查看单个索引信息

curl -XGET -u 'elastic:111111' 'http://127.0.0.1:9200/_cat/shards/estest?v'

4、查看集群所有索引信息

curl -XGET -u 'elastic:111111' 'http://127.0.0.1:9200/_cat/indices?v'

5、统计索引名包含estest的数量

curl -XGET -u 'elastic:111111' 'http://127.0.0.1:9200/_cat/indices' |grep 'estest'|wc -l

6、统计索引名包含estest,对第三列进行排序

curl -XGET -u 'elastic:111111' 'http://127.0.0.1:9200/_cat/indices' |grep 'estest'|sort -k 3

7、查看es集群健康状况

curl -XGET -u 'elastic:111111' 'http://127.0.0.1:9200/_cat/health?v'

8、es查看node节点

curl  -u 'elastic:111111' 127.0.0.1:9200/_cat/nodes|wc -l

8、es用api创建用户

curl -X PUT -H 'Content-Type: application/json' -u 'elastic:111111' --url 'http://127.0.0.1:9200/_xpack/security/user/username  -d ' { "password": "iie123$%^", "roles": ["username_role"] } '

9、给用户赋权

curl -X PUT  -H 'Content-Type: application/json' -u 'elastic:111111' --url 'http://127.0.0.1:9200/_xpack/security/role/username_role -d ' { "cluster":[],"indices":[{"names":["es_index_name"],"privileges":["read"]}]}'

10、修改用户密码

curl -X PUT -H 'Content-Type: application/json' -u 'elastic:111111' --url 'http://127.0.0.1:9200/_xpack/security/user/username/_password  -d ' { "password": "iie123$%^"} '

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值