File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
server/src/main/java/org/opensearch/cluster/routing Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -289,6 +289,12 @@ public GroupShardsIterator<ShardIterator> searchShards(
289289 if (slice != null ) {
290290 // Filter the returned shards for the given slice
291291 CollectionUtil .timSort (indexIterators );
292+ // We use the ordinal of the iterator in the group (after sorting) rather than the shard id, because
293+ // computeTargetedShards may return a subset of shards for an index, if a routing parameter was
294+ // specified. In that case, the set of routable shards is considered the full universe of available
295+ // shards for each index, when mapping shards to slices. If no routing parameter was specified,
296+ // then ordinals and shard IDs are the same. This mimics the logic in
297+ // org.opensearch.search.slice.SliceBuilder.toFilter.
292298 for (int i = 0 ; i < indexIterators .size (); i ++) {
293299 if (slice .shardMatches (i , indexIterators .size ())) {
294300 allShardIterators .add (indexIterators .get (i ));
You can’t perform that action at this time.
0 commit comments