ES 7.7.1 高效delete_by_query

index中数据量很大的时候会出现接口超时的情况,另外也会出现version conflict等问题。根据ES


参考文档

https://www.elastic.co/guide/en/elasticsearch/reference/7.x/docs-delete-by-query.html


1.delete by query

POST /user_profile_daily/_delete_by_query?conflicts=proceed&scroll_size=10000&wait_for_completion=false
{
  "query": {
   "bool": {
      "filter": [
        { "term": { "recordType": "video"   }}
      ],
      "must_not": [
        {"exists": {"field":"startAt"}
      }]
    }
  }
}


2./_task?detailed查看任务状态

GET /_tasks?detailed=true&actions=*/delete/byquery


3./_task/_cancel取消任务

POST /_tasks/_cancel?actions=*/delete/byquery


4.sql语句统计剩余条数

GET _sql?format=csv
{
  "query": """
  select count(*)  from user_profile_daily where recordType='video' and startAt is not null limit 10
  """
}
posted @ 2021-08-25 17:57  Arli  阅读(1144)  评论(0编辑  收藏  举报