File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
server/src/main/java/org/elasticsearch/action/search Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments