我正在 scala 中向 elasticsearch 发送 HTTP post。
Http(s"http://$elkIp:5051/$indexName/_delete_by_query")
.postData(s"""{ "query": { "terms": { "zip_id.keyword": [$zipIds]}}}""")
.header("Content-Type", "application/json")
.header("Charset", "UTF-8")
.options(HttpOptions.followRedirects(true)).asString
此帖子查询返回。
java.net.SocketTimeoutException
但是该任务在我使用验证的elasticsearch中排队_tasks API.
我想在 scala 代码中检查同一任务的状态,并希望在完成时返回响应。
任何建议表示赞赏。
你需要做的是添加?wait_for_completion=false https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html#docs-delete-by-query-task-api根据您的要求,您将得到<task_id>
立即回复。
然后,您可以通过点击定期检查任务状态/_tasks/<task_id>
。立刻completed: true
返回,那么你就知道任务已经执行完毕。
您还需要确保删除.tasks/task/<task_id>
当您的工作完成时,否则它将保留在任务索引中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)