0

I found this documentation about "update by query" request

https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-update-by-query.html

Question is: How add URL parameter to "_update_by_query" query:

The example I add:

pre_production/_update_by_query?slices=200&scroll_size=1000

How add this 2 parameters (slices, scroll_size) usign JAVA Api?

1 Answer 1

1

You can use the UpdateByQueryRequestBuilder instance in order to modify the number of slices:

UpdateByQueryRequestBuilder updateByQuery =
  UpdateByQueryAction.INSTANCE.newRequestBuilder(client);
updateByQuery.source("source_index")
    .source()
    .setSlices(200);                 <--- set the number of slices

However, to change the scroll_size parameter you need to access the underlying UpdateByQueryRequest instance as the builder doesn't have any setBatchSize() method. You can do it like this:

((UpdateByQueryRequest) updateByQuery.getRequest()).setBatchSize(1000);
Sign up to request clarification or add additional context in comments.

2 Comments

updateByQuery = updateByQuery.source(indexName) .filter(boolQuery) .script(script) .setSlices(200); ((UpdateByQueryRequest) updateByQuery.getRequest()).setBatchSize(1000); Like this?
If that compiles yes :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.