I am trying to reindex data in Elasticsearch without actually changing index names. I am ingesting data to indices based on monthly index names(index-%{+YYYY.MM}). I've seen concept of using aliases, but I am not sure how to create new index. Do I need to create index_new or index_new-%{+YYYY.MM}?
You must reindex into a new index so the name must be different from the old index. An alias is a good way to hide the actual index names from the query clients. That way you can create new versions of an index, call the Reindex API to build up the new index and finally point the alias to the new index.
In my company we also do monthly indices and from time to time we need to reindex because of mapping changes. In order to do that we have a simple rule for mapping an alias to an index:
The alias prefix is a common text string prepended to all our searchable aliases, it was needed to allow clients to search across all aliases (GET /<alias prefix>*/_search?q=...) while skipping over the indices (to avoid duplicate results). The index prefix is also a text string but only prepended to our indices and so only known to our internal systems, typically our indexer engine. This allows us to handle multiple versions of indices and easily change aliases without anyone noticing, e.g.:
So right now I have indices with the names "project-2017.08", "project-2017.09", "project-2017.10". In the Kibana end the index looks like "project-*".
Do I need to create 3 new indices with the names "sample-project-2017.08_v1" , "sample-project-2017.09_v1" , "sample-project-2017.10_v1" and point alias to the new indices?
If so, what about the next month's data? I am assuming I need to declare index template with required mapping so that next month's data will be distributed to project-2017.11 without any aliases.
I am totally confused how things work for monthly based indices. Please let me know if this is the correct process.
You should be able to create a new, updated index template that apply to all indices that starts with the pattern project-*. This will apply to all new indices being created, e.g. project-1017.11. If you then reindex the content of project-2017.09 into project-2017.09-1, the template will apply here as well. You should then be able to delete the project-2017.09 index and once this is done create an alias project-2017.09 that points to project-2017.09-1. If you are primarily querying through Kibana, the new index will still match the configured index pattern and you may not even need to create the alias.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.