0
点赞
收藏
分享

微信扫一扫

【架构-33】Ribbon、Nginx、Gateway之间的区别和联系

Ichjns 2024-11-05 阅读 8

说明: elastic:1235  账号:密码

           _isShare : 字段

1、 根据一个参数查询es

curl -XGET -u  elastic:1235   'http://10.223.73.3:9200/catalog/_search' \
-H 'Content-Type: application/json' \
-d '{"query":{"match":{"_isShare":{"query":"1"}}}}';

curl -XGET -u elastic:1235 'http://10.28.72.2:9200/catalog/_search' \
-H 'Content-Type: application/json' \
-d '{"query":{"term":{"cataId":"d422646cb4e9450e819893b86042ab5f"}}}';

2、根据Id 删除数据

curl -X DELETE   -u elastic:1235 http://10.225.74.56:9200/95213405963d495582ac7ca34ea12869
3、超过10000条后多次查询


curl -XGET -u elastic:1235 'http://10.28.71.3:9200/catalog/_search?scroll=3m' \
-H 'Content-Type: application/json' \
-d '{"size":10000,"query":{"match_all":{}},"_source":["cataId"]}'  >> 20240529scoll.txt
获取到:scroll_id

curl -XGET -u elastic:1235 'http://10.21.7.13:9200/_search/scroll' \
-H 'Content-Type: application/json' \
-d '{"scroll_id":"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAA-WxYWZTNIVldDSWFSTTZJTml5b0lkM0FmQQ==","scroll":"3m"}' >> 20240529scoll.txt ;

4、 es 数据格式化,只获取cataid
cat 20240904001.txt | jq '.hits.hits[]._source.cataId | .cataTitle'  >> 20240904002.txt

5、去掉双引号

sed -i 's/\"/''/g' 20241023161.txt

6、 多个字段获取拼接
cat 20240904001.txt | jq -r '.hits.hits[] | [._source.cataTitle,._source.cataId,._id ] | join(",")'  >> 20240904002all.txt

7、 一个字段多个值查询


curl -XGET -u elastic:1235 'http://10.225.74.56:9200/catalog/_search' \
-H 'Content-Type: application/json' \
-d '{"size":10000,"query":{"match":{"groupId":["1d02a1d6ee144956b0e2502a7bd491e6","784fa48e4623460185603bc4b13d4d25"]}}}' >> 2024102313.txt;
8、 既不等于也不等于


curl -XGET -u elastic:1235 'http://10.225.74.56:9200/catalog/_search' \
-H 'Content-Type: application/json' \
-d '{"size":10000,"query":{"bool":{"must_not":[{"term":{"groupId":"fed0d0bd09424d1ea7c4b402d9f7b4af"}},{"term":{"isShare":"2"}}]}}}' >> 2024102316.txt;
9、更新字段数据
curl -XPOST -u elastic:1235 'http://10.225.74.56:9200/catalog/_update/b7f2d49a-6b3e-4af4-be40-b3a0b61c1551' \
-H 'Content-Type: application/json' \
-d '{    "doc":{        "labelNameMH":"一次性"    }}' ;

10 、删除多个索引
curl -XDELETE -u elastic:1235 'http://10.220.71.3:9200/index_test0402,catalog_copy,test_m'

11 、 模糊搜索
curl -XGET -u elastic:1235 'http://10.225.71.153:9200/operatelog/_search' \
-H 'Content-Type: application/json' \
-d '{"size":10,"query":{"wildcard":{"createTime":"*2023*"}},"_source":["logId"]}';

12 、根据Id精确查询

curl -XGET -u elastic:1235 'http://10.225.74.56:9200/catalog/_search' \
-H 'Content-Type: application/json' \
-d '{"size":10,"query":{"term":{"cataId":"b7f2d49a-6b3e-4af4-be40-b3a0b61c1551"}}}'

13、查看索引文档个数
curl -XGET -u elastic:1235 'http://10.213.71.1:9200/operatelog/_count'

14、 创建只读角色
curl -XPOST -u elastic:1235 'http://10.145.71.1:9200/_security/role/read_all_indices' \
-H 'Content-Type: application/json' \
-d '{ "indices":[{"names":["*"],"privileges":["read"]}],"cluster":["monitor"]}'
-- 创建只读用户
curl -XPOST -u elastic:1235 'http://10.145.74.56:9200/_security/user/readSjzt' \
-H 'Content-Type: application/json' \
-d '{"password":"sjztRead@2024","roles":"read_all_indices"}'
-- 验证权限
curl -XPUT -u readSjzt:sjztRead@2024 http://10.145.74.56:9200/index_test0528
curl -XGET -u readSjzt:sjztRead@2024 'http://10.145.74.56:9200/catalog/_search'

15、创建索引
curl -XPUT -u elastic:1235 http://10.145.71.1:9200/test_m

16、 查看所有索引

  curl -XGET -u elastic:1235 http://10.145.71.1:9200/_cat/indices?v

举报

相关推荐

0 条评论