es 数据清理delete_by_query

bash 复制代码
POST /索引名/_delete_by_query?conflicts=proceed&scroll_size=2000&wait_for_completion=false&slices=36
{"size": 2000, 
  "query": {
    "bool": { 
      "must": [
        {
          "terms": {
              "rule_id": [
               800007
              ]
          }
      
        }
      ]
    }
  }
}

slices=36 一共的副本数量 主和副本总数。

scroll_size=2000 分批的数量。

conflicts=proceed 遇到版本冲突继续,

如果通过查询删除遇到版本冲突,将如何处理:终止或继续。默认为终止

wait_for_completion=false 放后台执行

通过调整这个两个参数控制性能和es压力

slices

scroll_size

查看后台任务id

bash 复制代码
GET _tasks?detailed=true&actions=*/delete/byquery&pretty

取消任务

bash 复制代码
POST /_tasks/ZGPDvWcgRXyuoWeiPFupcQ:23507301/_cancel

理论上删除数据以后后台会自动merge ,不用执行下面命令。

bash 复制代码
POST /index_name/_forcemerge?only_expunge_deletes=true

参考:

https://elasticsearch.bookhub.tech/rest_apis/document_apis/delete_by_query

https://www.elastic.org.cn/docs/8.1/www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html

相关推荐
IT大白鼠2 小时前
搜索系列 · 第 07 篇——调优实战:写入、查询与监控
elasticsearch·nosql
Elasticsearch6 小时前
检查 100 个候选项,而不是 1000 万个文档:更快速的 Elasticsearch kNN 过滤
elasticsearch
Elasticsearch7 小时前
当 AI agent 群集出现时,银行能跟上吗?
elasticsearch
Sayai1 天前
Elasticsearch 日志检索 DSL 实战:时间范围查询、字段去重、分钟级统计与最新日志获取
大数据·运维·elasticsearch·搜索引擎·日志分析
阿狗童鞋1 天前
Elasticsearch实战指南
大数据·elasticsearch·搜索引擎
IT大白鼠1 天前
搜索系列 · 第 04 篇——部署实操:内网集群落地
运维·elasticsearch·nosql
Elastic 中国社区官方博客1 天前
使用 Jev 作为 search reranker:基准测试与实现方法
大数据·运维·elasticsearch·全文检索
Elasticsearch1 天前
签名、密封、交付:使用 Vault 和 cert-manager 进行 ECK 证书管理
elasticsearch
看浪的路人1 天前
第5讲:Prompt 管理与版本追踪
大数据·数据库·elasticsearch
Elastic 中国社区官方博客2 天前
Kubernetes attributes processor v1:它对 EDOT Collector 意味着什么
java·大数据·elasticsearch·搜索引擎·贪心算法·kubernetes·全文检索