One alias with multiple indices

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

One alias with multiple indices

tao hiko
Hello,

I created a alias that contain multiple indices and I can get data without any error but insert/update data via alias that show below message

{
   "error": "ElasticsearchIllegalArgumentException[Alias [data-active] has more than one indices associated with it [[data-v4, data-v2, data-v3]], can't execute a single index op]",
   "status": 400
}

Actually, inserting and updating are working on data-v4 only but I need to do via alias because I can reuse application code without any change.

Is it possible to configure something to do like that?


Thank you,
Hiko

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c6436e1d-a6d1-46c9-8303-e10bb883a8ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: One alias with multiple indices

Colin Goodheart-Smithe
Hi,

You can't use aliases which point to multiple indexes for indexing operations. This is because there is no way of elasticsearch knowing which index in your alias you want to apply the indexing operation to.

What you can do instead is to create another alias called something like 'data-write' and point it at the index you want to use to write data to. This way your application can always point to the alias (data-write) to write data and the alias (data-active) to read data. Then you can change the index in 'data-write' when the index you are wanting to write to changes (making sure you do the add an remove in a single request, example in [1]) and you can change the indexes in 'data-active' when the indexes you want to read/search from change.

Hope this makes sense

Colin

[1] http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html

On Wednesday, 18 February 2015 09:43:53 UTC, tao hiko wrote:
Hello,

I created a alias that contain multiple indices and I can get data without any error but insert/update data via alias that show below message

{
   "error": "ElasticsearchIllegalArgumentException[Alias [data-active] has more than one indices associated with it [[data-v4, data-v2, data-v3]], can't execute a single index op]",
   "status": 400
}

Actually, inserting and updating are working on data-v4 only but I need to do via alias because I can reuse application code without any change.

Is it possible to configure something to do like that?


Thank you,
Hiko

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8b736701-4ce6-49aa-b44d-1cd88418dcdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: One alias with multiple indices

tao hiko
In reply to this post by tao hiko
Hi Colin,

Thank you for your advice that is a good solution.

Thank you,
Hiko

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d46c709c-6940-4db9-9948-d2fb93dc50d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: One alias with multiple indices

VinsYu
This post has NOT been accepted by the mailing list yet.
In reply to this post by Colin Goodheart-Smithe
Hi Colin,

In may case, I have search_alias and index_alias. search_alias is pointing to 2 different index. However, when I'm calling a getById by call client.prepareGet(String index, @Nullable String type, String id) method,
I'm getting the same error as above "has more than one index associated with it"

When the user is doing search by ID, the program does not know which index to use. The indices basically, archive and active. So search_alias is pointing to archive and active and should be able to return results on both indices.

Thanks,
/Vins