AWS Elasticsearch - 按查询删除,如何查找任务 ID,以便在删除完成后可以继续执行代码,以及何时执行 wait_for _completion
我正在使用 AWS Lambda 对 Elasticsearch 索引执行 delete_by_query,以便删除超过 7 天的所有内容。这是可行的,但我注意到文档的计数前后是相同的,所以如果我要在 Elasticsearch 中运行查询,在 delete_by_query 完成之前我可能无法获得正确的结果。
我找到了这篇文章(python 3.x - 删除的正确方法然后重新索引 ES 文档 - Stack Overflow),其中指出“最好将 wait_for_completion 设置为 False。在这种情况下,您将获得任务详细信息并能够跟踪任务进度。”首先,我还没有找到任何说明为什么会出现这种情况的信息,除非像那个示例那样删除需要 4 个小时。
我在此处找到了确定delete_by_query是否仍在这个精彩网站上运行的代码尝试过:
es_client.tasks(detailed=True,actions="*/delete/byquery")
但是,我收到的消息是 “TasksClient”对象不可调用。
我不完全确定这是否属实,或者我的语法是否不正确,因此这就是它不起作用的原因。如果我可以在控制台中使用curl 执行任务,那么我无法使用python 以编程方式查询任务是没有意义的。
如果将 wait_for_completion 设置为 False 不好,并且我无法使用 Python 进行查询,那么我如何以编程方式获取有关任务的任何信息或了解我是否可以继续进行分析查询或其他任何我想要的操作?想要做什么取决于这个任务正在完成吗?
I'm using AWS Lambda to do a delete_by_query on an Elasticsearch index so I get rid of everything older than 7 days. That works, but I noticed that the count of the documents is the same before and after, so if I were to run a query in Elasticsearch I may not get correct results until the delete_by_query is completed.
I found this post (python 3.x - Right way to delete and then reindex ES documents - Stack Overflow) that states that it is "best to set wait_for_completion to False. In this case you'll get task details and will be able to track task progress." For one, I haven't found anything that states why this is the case, unless your delete takes 4 hours like that example.
I found code to determine if the delete_by_query is still running at this wonderful site here and tried:
es_client.tasks(detailed=True,actions="*/delete/byquery")
However, I'm getting the message that'TasksClient' object is not callable.
I am not entirely sure if that is true or not , or if my syntax is incorrect and thus that is why it is not working. It doesn't make sense that I can't programmatically query Tasks with python if I can do it in the console and with curl.
If it is not good to set wait_for_completion to False, and I can't query this with Python, how am I to programmatically get any information about the task or an understanding as to whether I can go ahead with the analytical queries or whatever else I want to do that depends on this task being done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我不完全确定你为什么会收到这个错误,所以我无法特别帮助你。但是,我注意到关于当 wait_for_completion 设置为 false 时如何从 delete_by_query 获取任务 id 的 python elasticsearch 文档不是很清楚,所以我将提供这个以防它有帮助。
希望有帮助!
Okay, I'm not entirely sure why you are getting that error, so I can't help with that in particular. But, I noticed that the python elasticsearch documentation on how to get the task id from the delete_by_query when wait_for_completion is set to false isn't very clear, so I'm going to provide this in case it helps.
Hope that helps!