I'm trying to reindex 2695140 documents, using Nest C#. I need to calculate how much time it taken to reindex all the documents, for which I've written the logs. But after running for 1 minute, my code is returning an invalid response (Failed) but the documents are getting indexed properly as we have triggered Reindex endoint of elastic search.
I would want my code should wait until the reindex operation is completed so that I can calculate the total time taken to reindex. Below is the code I'm using
return await Client.ReindexOnServerAsync(selector => selector
.Source(src => src
.Index(_config.SomeIndex))
.Destination(dest => dest
.Index(newIndexName).OpType(OpType.Index))
.WaitForCompletion(true));
Thanks in advance.
I don't know which programming language are you using but essentially for languages following "One Thread per Request" model it is not wise to wait for the reindex operation. The time taken by the operation will be proportional to the number of documents to re-index and it blocks the thread (consuming resource) until the operation is complete.
Instead you should: