首页 > 解决方案 > 有什么方法可以记录 Elasticsearch 7.x 中 delete_by_query 输出删除的 id

问题描述

在 python 中,我对 elasticsearch 库使用 delete_by_query 方法。这绝对很棒,只是我在官方文档中没有看到任何日志记录。那么,如何确保我们作为输入传递的所有 id 都被删除了呢?

现在我只依赖于运行查询前后的计数,但应该有一些我缺少的基本日志记录。有什么线索吗?这可能吗?

代码 :

from elasticsearch import Elasticsearch

es = Elasticsearch([{'host': host,'port': port}],timeout=timeout)

 entity_query = {
          "query": {
              "terms": {
                "_id": [] #list_of_ids_here
            }
       }
     }
res = es.delete_by_query(ind_name, query)
print(res)

标签: pythonelasticsearch

解决方案


推荐阅读