# Elasticsearch-java api for Slices doesn't have a way to specify 'auto' for reindexing?

**URL:** <https://discuss.elastic.co/t/elasticsearch-java-api-for-slices-doesnt-have-a-way-to-specify-auto-for-reindexing/380004>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [July 10, 2025, 3:51pm UTC](https://discuss.elastic.co/t/elasticsearch-java-api-for-slices-doesnt-have-a-way-to-specify-auto-for-reindexing/380004 "2025-07-10T15:51:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![buitcj](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@buitcj](https://discuss.elastic.co/u/buitcj)\
**Post date:** [July 10, 2025, 3:51pm UTC](https://discuss.elastic.co/t/elasticsearch-java-api-for-slices-doesnt-have-a-way-to-specify-auto-for-reindexing/380004/1 "2025-07-10T15:51:02Z")

</div>

It seems that Slices.java in v8 and v9 of the elasticsearch-java, there is no way to specify slices = 'auto'?

The REST API seems to to say 'auto' can be used ([Reindex documents | Elasticsearch API documentation](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-reindex#operation-reindex-slices))

But the java api doesn't _seem_ to have it.

Can someone confirm? If it indeed does not have a java binding, is there a workaround?

---

<div class="post-metadata">

**Author:** ![ltrotta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ltrotta/32/124003_2.png) [@ltrotta](https://discuss.elastic.co/u/ltrotta)\
**Post date:** [August 20, 2025, 3:13pm UTC](https://discuss.elastic.co/t/elasticsearch-java-api-for-slices-doesnt-have-a-way-to-specify-auto-for-reindexing/380004/2 "2025-08-20T15:13:10Z")

</div>

Hello!

Since the `slice` field in the ReindexDocument request can accept both integers and the “auto” string, in the java client it needs an extra step to be set, to identify the correct type. So to set “auto” you can use:

```java
Slices.of(s -> s.computed(SlicesCalculation.Auto));

```

and it’s the same for both 8.x and 9.x 🙂

---

<div class="post-metadata">

**Author:** ![buitcj](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@buitcj](https://discuss.elastic.co/u/buitcj)\
**Post date:** [August 20, 2025, 3:39pm UTC](https://discuss.elastic.co/t/elasticsearch-java-api-for-slices-doesnt-have-a-way-to-specify-auto-for-reindexing/380004/3 "2025-08-20T15:39:21Z")

</div>

wow, great, I thought this thread was dead! thank you so much I will have to give it a try

---

<div class="post-metadata">

**Author:** ![ltrotta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ltrotta/32/124003_2.png) [@ltrotta](https://discuss.elastic.co/u/ltrotta)\
**Post date:** [August 20, 2025, 4:01pm UTC](https://discuss.elastic.co/t/elasticsearch-java-api-for-slices-doesnt-have-a-way-to-specify-auto-for-reindexing/380004/4 "2025-08-20T16:01:56Z")

</div>

so sorry for the delay 🙏
