Search code examples
elasticsearchtire

Elasticsearch reindexing: How do you direct updates to the new index while it is being built?


I understand reindexing using an alias to avoid downtime, as described here: Is there a smarter way to reindex elasticsearch?

But one problem remains: Say the reindexing takes an hour, while the original DB keeps changing. I would need any updates to go to both indexes.

Is there any way to do that?

If not, I would prefer if updates went to the new index, while queries were still served from the old index. But at least in Tire, I haven't seen a way to use different indices for reading and writing. Can that be done?


Solution

  • You can't update two index at the same time from Elasticsearch. You can handle that on your side and 2 index requests to Elasticsearch.

    That said, you can probably use alias here althought I'm pretty sure you can search on more than one index using Tire (but I don't know Tire)

    You have an old index1

    Push all your content to index2 Add an alias index on top of index1, index2

    When indexing is finished remove index1