ES操作笔记

在这里插入图片描述

1 ES 按条件更新

curl --location --request POST 'http://elastic:123456@127.0.0.1:9200/test-index/_update_by_query' \
--header 'Content-Type: application/json' \
--data '{
    "script": {
        "source": "ctx._source.callCode = 'D002';",
        "lang": "painless"
    },
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "_id": "1358_2"
                    }
                }
            ]
        }
    },
    "size": 1
}'

2 ES 按条件删除

curl --location --request POST 'http://elastic:123456@127.0.0.1:9200/test-index/_doc/_delete_by_query' \
--header 'Content-Type: application/json' \
--data '{
    "query": {
        "bool": {
            "must": [
                {
                    "terms": {
                        "_id": [
                            "1358"
                        ]
                    }
                }
            ]
        }
    },
    "size": 5
}'

3 ES 按条件查询数量

curl --location --request POST 'http://elastic:123456@127.0.0.1:9200/test-index/_count' \
--header 'Content-Type: application/json' \
--data '{
    "query": {
        "bool": {
            "must": [
                {
                    "terms": {
                        "_id": [
                            "1358"
                        ]
                    }
                }
            ]
        }
    }
}'

4 ES 更新Mapping

curl --location --request PUT 'http://elastic:123456@127.0.0.1:9200/test-index/_mapping' \
--header 'Content-Type: application/json' \
--data-raw '{
    "properties": {
        "province": {
            "type": "keyword"
        },
        "municipal": {
            "type": "keyword"
        }
    }
}'

5 ES 删除索引

curl --location --request DELETE 'http://elastic:123456@127.0.0.1:9200/test-index/'

6 ES 添加数据

curl --location --request PUT 'http://elastic:123456@127.0.0.1:9200/test-index/_doc/1358_2' \
--header 'Content-Type: application/json' \
--data '{
    "id": "1358_2",
    "age": 5
}'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值