
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
}'