# Working with alias referencing multiple indices in Java native API

**URL:** <https://discuss.elastic.co/t/working-with-alias-referencing-multiple-indices-in-java-native-api/66242>\
**Category:** Elasticsearch\
**Created:** [November 16, 2016, 11:34am UTC](https://discuss.elastic.co/t/working-with-alias-referencing-multiple-indices-in-java-native-api/66242 "2016-11-16T11:34:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrvincnezo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mrvincnezo/32/10829_2.png) [@mrvincnezo](https://discuss.elastic.co/u/mrvincnezo)\
**Post date:** [November 16, 2016, 11:34am UTC](https://discuss.elastic.co/t/working-with-alias-referencing-multiple-indices-in-java-native-api/66242/1 "2016-11-16T11:34:15Z")

</div>

I am getting an exception when trying to use `prepareGet` API with aliases that reference more than one index. The exception message is self-explanatory and says that multi-index alias can't be used with single index operation.

I've am working with a daily index and I need to be able to get documents from a multi-index alias.

I assume I can use the multi-get API but it is more cumbersome and requires to

1. Get the list of indices from the alias
2. Prepare the multi get request
3. Iterate over the multi get responses

Is there an alternative solution? [Java REST client](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/index.html)?

Thanks.

---

<div class="post-metadata">

**Author:** ![mrvincnezo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mrvincnezo/32/10829_2.png) [@mrvincnezo](https://discuss.elastic.co/u/mrvincnezo)\
**Post date:** [November 16, 2016, 3:55pm UTC](https://discuss.elastic.co/t/working-with-alias-referencing-multiple-indices-in-java-native-api/66242/2 "2016-11-16T15:55:20Z")

</div>

I was able to use the multi-index alias with search API instead of get API. I guess it is less efficient but it is clear & simple.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 14, 2016, 3:55pm UTC](https://discuss.elastic.co/t/working-with-alias-referencing-multiple-indices-in-java-native-api/66242/3 "2016-12-14T15:55:55Z")

</div>

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