Skip to content

Commit f037bc0

Browse files
committed
Iter TransportSearchAction
1 parent fccadb1 commit f037bc0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,12 +1904,15 @@ static List<SearchShardIterator> getLocalShardsIteratorFromPointInTime(
19041904
try {
19051905
final ShardIterator shards = OperationRouting.getShards(projectState.routingTable(), shardId);
19061906
// Prefer executing shard requests on nodes that are part of PIT first.
1907-
if (projectState.cluster().nodes().nodeExists(perNode.getNode())) {
1907+
boolean nodeExists = projectState.cluster().nodes().nodeExists(perNode.getNode());
1908+
if (nodeExists) {
19081909
targetNodes.add(perNode.getNode());
19091910
}
1910-
for (ShardRouting shard : shards) {
1911-
if (shard.currentNodeId().equals(perNode.getNode()) == false) {
1912-
targetNodes.add(shard.currentNodeId());
1911+
if (perNode.getSearchContextId().getSearcherId() != null || nodeExists == false) {
1912+
for (ShardRouting shard : shards) {
1913+
if (shard.currentNodeId().equals(perNode.getNode()) == false) {
1914+
targetNodes.add(shard.currentNodeId());
1915+
}
19131916
}
19141917
}
19151918
} catch (IndexNotFoundException | ShardNotFoundException e) {

0 commit comments

Comments
 (0)