elasticsearch6.x curl 增删查改

创建索引

curl -H "Content-Type: application/json" -XPUT http://127.0.0.1:9200/index2 -d '{
    "settings" : {
        "number_of_shards" : 4,
        "number_of_replicas" : 0
    },
    "mappings" : {
            "properties" : {
                "field1" : { "type" : "long" },
                "field2" : { "type" : "text" }
        }
    }
}'

插入数据


curl -XPUT 'http://localhost:9200/index2/_doc/1' -H 'Content-Type: application/json' -d '{"field1"  : 6651 ,"field2"  : "111111"}'  (_doc 名字)

 

普通查删


curl -XGET http://localhost:9200/index2/_doc/_search?q=field2:111111

查找索引全部数据

 curl -XDELETE http://127.0.0.1:9200/x-x

删除索引

 

高级查询

curl -XGET 'http://127.0.0.1:9200/xxx/_doc/_search' -H "Content-Type: application/json" -d '{
    "query": {
        "match": {
            ""host_ip": "10.229.31.226"
        }
    }
}'

根据条件查找索引


curl -XGET 'http://localhost:9200/_cluster/health?pretty'

查看集群状态

 

curl -XPOST 'localhost:9200/xxxx/_search?pretty' -H "Content-Type: application/json" -d '{"query": { "match": {"ip.keyword": "xxx"}},"sort":{"create_time.keyword":{"order":"desc"}},"size": 1}'

排序查最新一条数据

 

curl -XPOST 'localhost:9200/xxxx/_search?pretty' -H "Content-Type: application/json" -d '{"query": {"bool": {"must": [{"match": {"ip.keyword": "行行行"}}],"filter": {"range": {"create_time.keyword": {"gte": "2021-04-02 12:00:07","lte": "2021-04-02 12:02:07"}}}}}}' 

查询指定时间内并带过滤条件的数据(抓某行的的话可以利用 | grep xxx , 并且定向输出到数据 >>1.txt)

 

修改设置

修改字段设置
curl -i -H "Content-Type: application/json" -X PUT -d "{\"index.mapping.total_fields.limit\":\"2100\"}" http://127.0.0.1:9200/x-x/_settings/


查看下字段设置
curl -XGET 'http://127.0.0.1:9200/x-x/_settings'

 

curl -XGET http://127.0.0.1:9200/x-x/_search?pretty
查看es线程 cpu使用量

 

curl http://localhost:9200/_nodes/hot_threads

热线程

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值