Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Delete child documents without parent #689

Open
ilijaplusx opened this issue Aug 25, 2020 · 0 comments
Open

Delete child documents without parent #689

ilijaplusx opened this issue Aug 25, 2020 · 0 comments

Comments

@ilijaplusx
Copy link

As the title says, I'm trying to delete all the parentless child documents using Jest. If I got things correctly, I need to use DeleteByQuery, and my proposed solution is this:

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()

However, I get routing_missing_exception. Investigating online, it seems I need to set parent type for routing, however, apart from specifying it in hasParentQuery idk where else I need to add it?

Although I found some examples how to do it with REST API, I wasn't able to find ones that use Jest, so hopefully someone can help out.

I'm using Elasticsearch 5.5.

This question is also posted on Stackoverflow.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant