Elasticsearch Performance Issue

Nested documents are stored as separate documents behind the scenes in Elasticsearch. When you add or update a nested document ALL nested documents need to be reindexed, which can quickly become expensive and is one of the main drawbacks with nested documents.

In your case it sounds like each nested document is updated individually and that each document on average have around 57 nested documents. This means that updating each of the nested documents individually will cause (57+1) * 57 = 3,306 documents to be reindexed behind the scenes as all documents need to be reindexed for every update.

Another issue that is probably hurting performance is that you are updating the same document many times. Updating a single document frequently can quickly lead to poor performance as it can generate many small segments (which is an expensive operation).

My advice would therefore be to group all updates by document and perform one single large update per document rather than many small ones. That should greatly improve your performance. I do not think there is any magical tuning that will greatly improve performance without changing how you handle updates.

1 Like