es根据条件删除数据备份索引等操作

1.删除索引数据

POST /索引名称/_delete_by_query   
{
    "query": {
        "bool": {
            "must_not": [
                {
                    "match": {
                        "test": "字段值"
                    }
                }
            ]
        }
  }
}

2.从一个索引数据导入另一个索引里
POST _reindex
{
  "source": {
    "index": "test_20201207",

    "size":5000
  },
  "dest": {
    "index": "test_20201208"
  }
}

3.查询索引结构

GET /索引名称/_mapping?pretty

4.查询索引数据

GET /索引名称/_search

5.创建模板

curl -H "Content-Type: application/json" -XPUT  "ip:9201/_template/模板名称?pretty" -d '{
 "template" : "模板名称*",

"settings" : {       
        "number_of_shards" : 10, 
        "number_of_replicas" : 1,
        "index.max_result_window": 1000000000
    },
    "mappings" : {
   "properties" : {
        "test1" : {
          "type" : "keyword"
        },
        "test2" : {
          "type" : "long"
        }
        
      }
    }
}'

6.增加或更新数据

PUT /_bulk
{"index":{"_index" : "索引名称","_type" : "_doc","_id" : "1189866394802000"}}
{"test1": "12345", "test2": "889999"}

7.删除索引

DELETE /索引名称

8.修改索引的字段值

POST /索引名称/_update_by_query
{
    "query": {
        "bool": {
            "must": [
                {
                    "match": {
                        "status": "1"
                    }
                }
            ]
        }
  },
    "script": {
        "inline": "ctx._source['major'] = 'net';ctx._source['com_name'] = 'lisi'"
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值