Delete child documents without parent using Java API

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

val allParentlessChildren = QueryBuilders
val delete = new DeleteByQuery.Builder(allParentlessChildren.toString)

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 Java API, so hopefully someone can help out.

I'm using Elasticsearch 5.5.

I've posted it on Stackoverflow as well.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.