Reputation: 519
I am trying to achieve updating the data in the indices of Elasticsearch with zero downtime but I am not sure how to achieve this. Can anyone assist me how I can do so?
For example: If I have an index of name my_es_index
and I want to update the data in that particular index with zero downtime so that the old data is still there on one of the node while someone is performing certain query but parallelly in the backend , we are updating the data on that index.
Is it possible to achieve? If yes, please help me with how I can proceed.
Upvotes: 0
Views: 1005
Reputation: 607
Unless you are to update the mapping of an existing field and preserving the name of the fields is required, I don't think taking the cluster down is needed.
While the above article is a good read and might be treated as best practices, ES is a lot flexible. Unlike MySQL/SQL, it allows you to update existing documents.
Adding a new field
Let's call the new field to be added as x
.
x
.x
.x
, write-up a script which updates the older documents and adds this field x
.x
, you may enable the feature you added this field for.Updating mapping of a field
Let's again call the field to be updated as x
(assuming the name of the field is not the prime concern).
new_x
(add correct mapping to the index).new_x
has the data (slight change that we need to ensure both x
and new_x
have this data).new_x
, simply refactor the code to use new_x
instead of x
.While one might argue that above two approaches are in a way hacks, it saves you time, effort and cost to boot up a new ES instance and manage the aliases.
Upvotes: 0
Reputation: 52536
You build/create another index (we called new index), then switch from old index to new index, then delete old index.
Read more at https://medium.com/craftsmenltd/rebuild-elasticsearch-index-without-downtime-168363829ea4
Upvotes: 3