简体   繁体   中英

How set scroll_size to _update_by_query request from JAVA API

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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