ElasticSearch异步删除

it2023-06-03  79

ES删除数据时经常会超时,使用异步task方式删除,将任务存入后台执行。

执行后台删除 wait_for_completion=false GET uint/_delete_by_query?wait_for_completion=false { "size": 20, "timeout": "1200s", "query": { "bool": { "must": [ { "range": { "clock": { "gte": 1546272000, "lt": 1558281599 } } } ], "filter": { "script": { "script": { "source": "(doc['clock'].value.millis/1000+doc['ttl'].value)<1571500799" } } } } } } --返回数据 { "task": "LexxnjDDSzuHmgl_rk1M7g:166676765" } 查询某个任务的执行情况(根据返回的taskid查询) GET _tasks/LexxnjDDSzuHmgl_rk1M7g:166676765 { "completed": false, "task": { "node": "LexxnjDDSzuHmgl_rk1M7g", "id": 166676765, "type": "transport", "action": "indices:data/write/delete/byquery", "status": { "total": 473381022, "updated": 0, "created": 0, "deleted": 53820, "batches": 2692, "version_conflicts": 0, "noops": 0, "retries": { "bulk": 0, "search": 0 }, "throttled_millis": 0, "requests_per_second": -1, "throttled_until_millis": 0 }, "description": "delete-by-query [uint]", "start_time_in_millis": 1603181880309, "running_time_in_nanos": 145234246089, "cancellable": true, "headers": {} } } 查询所有后台删除任务状态 GET _tasks?detailed=true&actions=*/delete/byquery { "nodes": { "LexxnjDDSzuHmgl_rk1M7g": { "name": "ES01Kibana", "transport_address": "192.168.xx.xx:9300", "host": "192.168.xx.xx", "ip": "192.168.xx.xx:9300", "roles": [], "attributes": { "ml.machine_memory": "8184184832", "xpack.installed": "true", "ml.max_open_jobs": "20", "ml.enabled": "true" }, "tasks": { "LexxnjDDSzuHmgl_rk1M7g:165886152": { "node": "LexxnjDDSzuHmgl_rk1M7g", "id": 165886152, "type": "transport", "action": "indices:data/write/delete/byquery", "status": { "total": 220638482, "updated": 0, "created": 0, "deleted": 1827240, "batches": 91362, "version_conflicts": 0, "noops": 0, "retries": { "bulk": 0, "search": 0 }, "throttled_millis": 0, "requests_per_second": -1, "throttled_until_millis": 0 }, "description": "delete-by-query [uint]", "start_time_in_millis": 1603178535366, "running_time_in_nanos": 3007636586529, "cancellable": true, "headers": {} } } } } } 取消指定任务 POST _tasks/LexxnjDDSzuHmgl_rk1M7g:165886152/_cancel
最新回复(0)