Elasticsearch之curl常用操作

  • 查询
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查询语法

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值