- 查询
curl -k -u elastic:elastic -XGET http://192.168.151.182:9200/_search?pretty
- 查看索引
GET _cat/indices
curl -k -u elastic:elastic 'http://192.168.151.182:9200/_cat/indices?v'
- 查看索引结构
curl -k -u elastic:elastic -XGET 'http://192.168.151.182:9200/c_index/_mapping?pretty'
- 修改指定字段都值
POST snapshot_ngram/_update_by_query?conflicts=proceed
{
"script": {
"type": "inline",
"source": "ctx._source.deleted=123",
"lang": "painless"
},
"query": {
"bool": {
"must": [
{
"term": {
"corpid": {
"value": "wwd074f0"
}
}
},
{
"term": {
"customer_id": {
"value": "479464657254592"
}
}
}
]
}
}
}
- 添加索引
curl -k -u elastic:elastic -H 'Content-Type: application/json' -XPUT http://192.168.151.182:9200/c_index -d '
{
"mappings": {
"properties": {
"id": {
"type": "integer"
},
"country": {
"type": "text"
},
"city": {
"type": "text"
}
}
}
}'
- 删除索引
curl -k -u elastic:elastic -XDELETE http://192.168.151.182:9200/c_index
- 查看别名
GET _cat/aliases
curl -k -u elastic:elastic 'http://192.168.151.182:9200/_cat/aliases?v&pretty'
- 添加别名
curl -k -u elastic:elastic -H 'Content-Type: application/json' -XPOST 'http://192.168.151.182:9200/_aliases' -d '
{
"actions": [
{"add": {"index": "demo", "alias": "alias1"}}
]
}'
- 删除别名
curl -k -u elastic:elastic -H 'Content-Type: application/json' -XPOST 'http://192.168.151.182:9200/_aliases' -d '
{
"actions": [
{"remove": {"index": "demo", "alias": "demod"}}
]
}'
elasticdump
#安装node
tar -xf node-v10.15.0-linux-x64.tar.xz
echo 'PATH=$PATH:/opt/node-v10.15.0-linux-x64/bin' >> /etc/profile
source /etc/profile
#修改node默认仓库
npm config set registry http://registry.npm.taobao.org
npm install elasticdump -g
- 导出
/usr/local/node-v14.16.0-linux-x64/bin/elasticdump --input=http://192.168.0.99:9200/effect_chat --output=http://192.168.0.99:9200/effect_chat_202301 --searchBody='{"query":{"bool":{"must":[{"range":{"effect_date":{"gte":"2023-01-01 00:00:00","lt":"2023-02-01 00:00:00"}}}]}}}' --limit 5000
- 导入
elasticdump --limit 5000 --input=./snapshot_ngram.json --output=http://127.0.0.1:9200/snapshot_ngram
参考文章:
elasticsearch别名使用指南
curl命令操作elasticsearch
ElasticSearch之CURL操作
ElasticSearch 7
es查询语句
ES查询语法