繁体   English   中英

使用 Jest 在 Elasticsearch 中删除没有父级的子文档

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM