diff --git a/server/src/main/java/org/elasticsearch/search/SearchService.java b/server/src/main/java/org/elasticsearch/search/SearchService.java index 7f7b3bacc12ae..9b1f0b3f2dd0b 100644 --- a/server/src/main/java/org/elasticsearch/search/SearchService.java +++ b/server/src/main/java/org/elasticsearch/search/SearchService.java @@ -30,6 +30,7 @@ import org.elasticsearch.action.support.TransportActions; import org.elasticsearch.cluster.ProjectState; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.ResolvedExpression; +import org.elasticsearch.cluster.routing.RecoverySource; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedSupplier; @@ -531,7 +532,7 @@ public void beforeIndexShardCreated(ShardRouting routing, Settings indexSettings // to stop searches to restore full availability as fast as possible. A known scenario here is that we lost connection to master // or master(s) were restarted. assert routing.initializing(); - if (routing.isRelocationTarget() == false) { + if (routing.isRelocationTarget() == false && routing.recoverySource() != RecoverySource.EmptyStoreRecoverySource.INSTANCE) { freeAllContextsForShard(routing.shardId()); } }