diff --git a/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java b/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java index 125041f02b5..6f084684b0d 100644 --- a/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java +++ b/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java @@ -964,16 +964,7 @@ public final class NodeEnvironment implements Closeable { final Set shardIds = new HashSet<>(); final String indexUniquePathId = index.getUUID(); for (final NodePath nodePath : nodePaths) { - Path location = nodePath.indicesPath; - if (Files.isDirectory(location)) { - try (DirectoryStream indexStream = Files.newDirectoryStream(location)) { - for (Path indexPath : indexStream) { - if (indexUniquePathId.equals(indexPath.getFileName().toString())) { - shardIds.addAll(findAllShardsForIndex(indexPath, index)); - } - } - } - } + shardIds.addAll(findAllShardsForIndex(nodePath.indicesPath.resolve(indexUniquePathId), index)); } return shardIds; }