当前位置:   article > 正文

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

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/672467
推荐阅读
相关标签
  

闽ICP备14008679号