Pass batch size in deleteByQuery [elasticsearch] [scala]

I need to pass batch size while using deletebyQuery.

My requirement is:

  • Get x rows based on filters
  • Run DeletebyQuery on them
  • Return this list

While doing search using filters, there can 1000 rows but I need only batch of top 100. Need to return these 100 rows and run deleteByQuery, only on these 100.

What is the way to do this?

Here is the code of what I tried, but it ended up deleting all 1000 rows.

val searchQuery =
      termQuery(Type.status, Type.state)))


 val result = elasticsearchClient().execute (
    deleteByQuery(, Index.typeName,
      boolQuery.should(termQuery(Type.status, Type.state))).size(100))

size will be supported until ES version 8 but it doesnt seem to respect the size I pass.

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