[英]Delete documents from elasticsearch in Scala using RestClient
[英]Delete child documents without parent in Elasticsearch using Jest
正如標題所說,我正在嘗試使用 Jest 刪除所有無父子文檔。 如果我做對了,我需要使用 DeleteByQuery,我建議的解決方案是這樣的:
val allParentlessChildren = QueryBuilders
.boolQuery()
.mustNot(JoinQueryBuilders.hasParentQuery(
"my_parent",
QueryBuilders.matchAllQuery(),
false)
)
val delete = new DeleteByQuery.Builder(allParentlessChildren.toString)
.addIndex("my_index")
.addType("my_child")
.build()
但是,我得到了routing_missing_exception
。 在線調查,似乎我需要為路由設置父類型,但是,除了在hasParentQuery
idk 中指定它hasParentQuery
,我還需要在哪里添加它?
盡管我找到了一些如何使用 REST API 進行操作的示例,但我找不到使用 Jest 的示例,因此希望有人可以提供幫助。
我正在使用 Elasticsearch 5.5。
只需要添加路由,然而,在 Jest 中它似乎隱藏在setParameter
方法中:
val delete = new DeleteByQuery.Builder(allParentlessChildren.toString)
.addIndex("my_index")
.addType("my_child")
.setParameter(Parameters.ROUTING, "my_parent") // <-- added line
.build()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.