Skip to content

Commit e552e14

Browse files
committed
Mirror upstream elastic#136871 as single snapshot commit for AI review
BASE=9aed5f4584bafbbaa6129d3ee2345b56ddb744c9 HEAD=ffbe556e736c1294091045b07d78d5da2d70e53d Branch=main
1 parent 9aed5f4 commit e552e14

File tree

11 files changed

+259
-31
lines changed

11 files changed

+259
-31
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ public boolean allowsRemoteIndices() {
163163
return true;
164164
}
165165

166+
@Override
167+
public boolean allowsCrossProject() {
168+
return true;
169+
}
170+
166171
/**
167172
* Creates a new sub-search request starting from the original search request that is provided.
168173
* For internal use only, allows to fork a search request into multiple search requests that will be executed independently.

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,13 +609,18 @@ public Clusters(StreamInput in) throws IOException {
609609
}
610610

611611
public Clusters(Map<String, Cluster> clusterInfoMap) {
612+
this(clusterInfoMap, true);
613+
}
614+
615+
public Clusters(Map<String, Cluster> clusterInfoMap, boolean ccsMinimizeRoundtrips) {
612616
assert clusterInfoMap.size() > 0 : "this constructor should not be called with an empty Cluster info map";
613617
this.total = clusterInfoMap.size();
614-
this.clusterInfo = clusterInfoMap;
618+
this.clusterInfo = ConcurrentCollections.newConcurrentMap();
619+
this.clusterInfo.putAll(clusterInfoMap);
615620
this.successful = getClusterStateCount(Cluster.Status.SUCCESSFUL);
616621
this.skipped = getClusterStateCount(Cluster.Status.SKIPPED);
617622
// should only be called if "details" section of fromXContent is present (for ccsMinimizeRoundtrips)
618-
this.ccsMinimizeRoundtrips = true;
623+
this.ccsMinimizeRoundtrips = ccsMinimizeRoundtrips;
619624
}
620625

621626
@Override

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.elasticsearch.action.ActionRequestValidationException;
1313
import org.elasticsearch.action.IndicesRequest;
1414
import org.elasticsearch.action.LegacyActionRequest;
15+
import org.elasticsearch.action.ResolvedIndexExpressions;
1516
import org.elasticsearch.action.support.IndicesOptions;
1617
import org.elasticsearch.common.io.stream.StreamInput;
1718
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -43,6 +44,8 @@ public final class SearchShardsRequest extends LegacyActionRequest implements In
4344

4445
private final String clusterAlias;
4546

47+
private ResolvedIndexExpressions resolvedIndexExpressions;
48+
4649
public SearchShardsRequest(
4750
String[] indices,
4851
IndicesOptions indicesOptions,
@@ -179,4 +182,14 @@ public int hashCode() {
179182
result = 31 * result + Arrays.hashCode(indices);
180183
return result;
181184
}
185+
186+
@Override
187+
public void setResolvedIndexExpressions(ResolvedIndexExpressions expressions) {
188+
this.resolvedIndexExpressions = expressions;
189+
}
190+
191+
@Override
192+
public ResolvedIndexExpressions getResolvedIndexExpressions() {
193+
return resolvedIndexExpressions;
194+
}
182195
}

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99

1010
package org.elasticsearch.action.search;
1111

12+
import org.elasticsearch.TransportVersion;
1213
import org.elasticsearch.action.ActionResponse;
14+
import org.elasticsearch.action.ResolvedIndexExpressions;
1315
import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsGroup;
1416
import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsResponse;
1517
import org.elasticsearch.cluster.node.DiscoveryNode;
1618
import org.elasticsearch.common.io.stream.StreamInput;
1719
import org.elasticsearch.common.io.stream.StreamOutput;
1820
import org.elasticsearch.common.util.Maps;
21+
import org.elasticsearch.core.Nullable;
1922
import org.elasticsearch.index.Index;
2023
import org.elasticsearch.index.shard.ShardId;
2124
import org.elasticsearch.search.internal.AliasFilter;
@@ -35,28 +38,50 @@ public final class SearchShardsResponse extends ActionResponse {
3538
private final Collection<SearchShardsGroup> groups;
3639
private final Collection<DiscoveryNode> nodes;
3740
private final Map<String, AliasFilter> aliasFilters;
41+
private final ResolvedIndexExpressions resolvedIndexExpressions;
42+
public static final TransportVersion SEARCH_SHARDS_RESOLVED_INDEX_EXPRESSIONS = TransportVersion.fromName(
43+
"search_shards_resolved_index_expressions"
44+
);
3845

3946
public SearchShardsResponse(
4047
Collection<SearchShardsGroup> groups,
4148
Collection<DiscoveryNode> nodes,
42-
Map<String, AliasFilter> aliasFilters
49+
Map<String, AliasFilter> aliasFilters,
50+
@Nullable ResolvedIndexExpressions resolvedIndexExpressions
4351
) {
4452
this.groups = groups;
4553
this.nodes = nodes;
4654
this.aliasFilters = aliasFilters;
55+
this.resolvedIndexExpressions = resolvedIndexExpressions;
56+
}
57+
58+
public SearchShardsResponse(
59+
Collection<SearchShardsGroup> groups,
60+
Collection<DiscoveryNode> nodes,
61+
Map<String, AliasFilter> aliasFilters
62+
) {
63+
this(groups, nodes, aliasFilters, null);
4764
}
4865

4966
public SearchShardsResponse(StreamInput in) throws IOException {
5067
this.groups = in.readCollectionAsList(SearchShardsGroup::new);
5168
this.nodes = in.readCollectionAsList(DiscoveryNode::new);
5269
this.aliasFilters = in.readMap(AliasFilter::readFrom);
70+
if (in.getTransportVersion().supports(SEARCH_SHARDS_RESOLVED_INDEX_EXPRESSIONS)) {
71+
this.resolvedIndexExpressions = in.readOptionalWriteable(ResolvedIndexExpressions::new);
72+
} else {
73+
this.resolvedIndexExpressions = null;
74+
}
5375
}
5476

5577
@Override
5678
public void writeTo(StreamOutput out) throws IOException {
5779
out.writeCollection(groups);
5880
out.writeCollection(nodes);
5981
out.writeMap(aliasFilters, StreamOutput::writeWriteable);
82+
if (out.getTransportVersion().supports(SEARCH_SHARDS_RESOLVED_INDEX_EXPRESSIONS)) {
83+
out.writeOptionalWriteable(resolvedIndexExpressions);
84+
}
6085
}
6186

6287
/**
@@ -114,4 +139,9 @@ static SearchShardsResponse fromLegacyResponse(ClusterSearchShardsResponse oldRe
114139
public String toString() {
115140
return "SearchShardsResponse{" + "groups=" + groups + ", nodes=" + nodes + ", aliasFilters=" + aliasFilters + '}';
116141
}
142+
143+
@Nullable
144+
public ResolvedIndexExpressions getResolvedIndexExpressions() {
145+
return resolvedIndexExpressions;
146+
}
117147
}

0 commit comments

Comments
 (0)