Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to write to multiple indexes with an ElasticSearch alias?

Tags:

The ElasticSearch Docs reads:

An alias can also be mapped to more than one index, and when specifying it, the alias will automatically expand to the aliases indices.

But when I try to add an alias to 2 indices and write to both, neither seem to get updated with the document. If I remove one of the aliases, it will write correctly to the alias that still exists.

Fails with multiple write aliases:

$ curl -XGET 'http://localhost:9200/_aliases' 

result:

{   "dev_01": {     "aliases": {       "dev_read": {},       "dev_write": {}     }   },   "dev": {     "aliases": {       "dev_write": {}     }   } } 

Works with single alias:

$ curl -XGET 'http://localhost:9200/_aliases' 

result:

{   "dev_01": {     "aliases": {       "dev_read": {},       "dev_write": {}     }   },   "dev": {     "aliases": {}   } } 

Does elasticsearch support writing to multiple indices? Are aliases Read-Only if pointed at multiple indices?

like image 818
MattoTodd Avatar asked Oct 29 '13 15:10

MattoTodd


People also ask

How does alias work in Elasticsearch?

An alias is a secondary name for a group of data streams or indices. Most Elasticsearch APIs accept an alias in place of a data stream or index name. You can change the data streams or indices of an alias at any time.

Can Elasticsearch have multiple indexes?

This is kind of a waste, because each index only contains documents of a single type, and Elasticsearch offers the ability have multiple types on an index.

How do I query multiple indices in Elasticsearch?

To search multiple data streams and indices, add them as comma-separated values in the search API's request path. The following request searches the my-index-000001 and my-index-000002 indices. You can also search multiple data streams and indices using an index pattern.

How many indexes can Elasticsearch handle?

Indexes themselves have no limit, however shards do, the recommended amount of shards per GB of heap is 20(JVM heap - you can check on kibana stack monitoring tab), this means if you have 5GB of JVM heap, the recommended amount is 100.


1 Answers

the answer is No

So it appears I should have triaged this a beep deeper, but the response my client gets from es is:

ElasticSearchIllegalArgumentException[Alias [dev_write] has more than one indices associated with it [[dev_01, dev]], can't execute a single index op

Just wish the docs were a little more explicit up front, as they confused me a bit

At first seems to imply you can:

The index aliases API allow to alias an index with a name, with all APIs automatically converting the alias name to the actual index name. An alias can also be mapped to more than one index...

Associating an alias with more than one index are simply several add actions...

Further down the page lets you know you can not:

It is an error to index to an alias which points to more than one index.

like image 93
MattoTodd Avatar answered Oct 12 '22 10:10

MattoTodd