Skip to content

Commit

Permalink
ensure that indices are ordered consistently when extracted from a PI…
Browse files Browse the repository at this point in the history
…T. Removes the indices from transform pit search requests.
  • Loading branch information
jimczi committed Dec 7, 2023
1 parent 99c9efa commit c2388ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;

public final class SearchContextId {
Expand Down Expand Up @@ -132,7 +132,8 @@ private static void readShardsMapEntry(StreamInput in, Map<ShardId, SearchContex
}

public String[] getActualIndices() {
final Set<String> indices = new HashSet<>();
// ensure that the order is consistent
final Set<String> indices = new TreeSet<>();
for (Map.Entry<ShardId, SearchContextIdForNode> entry : shards().entrySet()) {
final String indexName = entry.getKey().getIndexName();
final String clusterAlias = entry.getValue().getClusterAlias();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,10 @@ void doSearch(Tuple<String, SearchRequest> namedSearchRequest, ActionListener<Se
logger.trace("searchRequest: [{}]", searchRequest);

PointInTimeBuilder pit = searchRequest.pointInTimeBuilder();
if (pit != null) {
// remove the indices from the request, they will be derived from the provided pit
searchRequest = new SearchRequest(searchRequest).indices(new String[0]);
}

ClientHelper.executeWithHeadersAsync(
transformConfig.getHeaders(),
Expand Down

0 comments on commit c2388ec

Please sign in to comment.