# Updating a document in an aliased index collection

**URL:** <https://discuss.elastic.co/t/updating-a-document-in-an-aliased-index-collection/9725>\
**Category:** Elasticsearch\
**Created:** [November 15, 2012, 12:07pm UTC](https://discuss.elastic.co/t/updating-a-document-in-an-aliased-index-collection/9725 "2012-11-15T12:07:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karussell\_2](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@Karussell\_2](https://discuss.elastic.co/u/Karussell_2)\
**Post date:** [November 15, 2012, 12:07pm UTC](https://discuss.elastic.co/t/updating-a-document-in-an-aliased-index-collection/9725/1 "2012-11-15T12:07:07Z")

</div>

Hi,

the task is to update a document which lays in one of serveral indices (all  
of them with the same alias).

I cannot feed when using the alias (pointing to multiple indices) - this  
makes sense, but why is the update API not working? Couldn't ElasticSearch  
get the concrete index as well as the document when searching and then use  
that to do the update?

The problem behind this task is that one index gets bigger and we want to  
split it in the near future to improve feeding time. But when we would feed  
into only one index then ElasticSearch will create a new document even if  
it exists in another index.

Regards,  
Peter.

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [November 15, 2012, 8:17pm UTC](https://discuss.elastic.co/t/updating-a-document-in-an-aliased-index-collection/9725/2 "2012-11-15T20:17:43Z")

</div>

During update elasticsearch doesn't search for a document, it "gets" the  
document instead. That's why it needs to know exactly where document is  
located. What you are describing sounds like a special use case of Update  
by Query [https://github.com/elasticsearch/elasticsearch/issues/1607](https://github.com/elasticsearch/elasticsearch/issues/1607)  
request.

On Thursday, November 15, 2012 7:07:07 AM UTC-5, Karussell wrote:

> Hi,
> 
> the task is to update a document which lays in one of serveral indices  
> (all of them with the same alias).
> 
> I cannot feed when using the alias (pointing to multiple indices) - this  
> makes sense, but why is the update API not working? Couldn't Elasticsearch  
> get the concrete index as well as the document when searching and then use  
> that to do the update?
> 
> The problem behind this task is that one index gets bigger and we want to  
> split it in the near future to improve feeding time. But when we would feed  
> into only one index then Elasticsearch will create a new document even if  
> it exists in another index.
> 
> Regards,  
> Peter.

--

---

<div class="post-metadata">

**Author:** ![karmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karmi/32/44951_2.png) [@karmi](https://discuss.elastic.co/u/karmi)\
**Post date:** [November 19, 2012, 2:31pm UTC](https://discuss.elastic.co/t/updating-a-document-in-an-aliased-index-collection/9725/3 "2012-11-19T14:31:09Z")

</div>

> I cannot feed when using the alias (pointing to multiple indices) - this  
> makes sense, but why is the update API not working? Couldn't Elasticsearch  
> get the concrete index as well as the document when searching and then use  
> that to do the update?

Until the "update by query" API is available, couldn't you just _search_  
for the document you want to update, using the alias, the type, and an ID,  
and then just use the regular AP? Because ES returns the "original",  
non-aliased index name in the response.

Karel

--

---

<div class="post-metadata">

**Author:** ![Karussell\_2](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@Karussell\_2](https://discuss.elastic.co/u/Karussell_2)\
**Post date:** [November 20, 2012, 12:24pm UTC](https://discuss.elastic.co/t/updating-a-document-in-an-aliased-index-collection/9725/4 "2012-11-20T12:24:59Z")

</div>

Hey, thank you both. Yes, searching is an option. I hoped to avoid somehow  
the fetching to the client.

Peter.

On Monday, November 19, 2012 3:31:09 PM UTC+1, Karel Minařík wrote:

> I cannot feed when using the alias (pointing to multiple indices) - this
> 
> > makes sense, but why is the update API not working? Couldn't Elasticsearch  
> > get the concrete index as well as the document when searching and then use  
> > that to do the update?
> 
> Until the "update by query" API is available, couldn't you just _search_  
> for the document you want to update, using the alias, the type, and an ID,  
> and then just use the regular AP? Because ES returns the "original",  
> non-aliased index name in the response.
> 
> Karel

--

---

<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:** [July 6, 2017, 3:03am UTC](https://discuss.elastic.co/t/updating-a-document-in-an-aliased-index-collection/9725/5 "2017-07-06T03:03:34Z")

</div>


