Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ public boolean allowsRemoteIndices() {
return true;
}

@Override
public boolean allowsCrossProject() {
return true;
}

/**
* Creates a new sub-search request starting from the original search request that is provided.
* For internal use only, allows to fork a search request into multiple search requests that will be executed independently.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,18 @@ public Clusters(StreamInput in) throws IOException {
}

public Clusters(Map<String, Cluster> clusterInfoMap) {
this(clusterInfoMap, true);
}

public Clusters(Map<String, Cluster> clusterInfoMap, boolean ccsMinimizeRoundtrips) {
assert clusterInfoMap.size() > 0 : "this constructor should not be called with an empty Cluster info map";
this.total = clusterInfoMap.size();
this.clusterInfo = clusterInfoMap;
this.clusterInfo = ConcurrentCollections.newConcurrentMap();
this.clusterInfo.putAll(clusterInfoMap);
this.successful = getClusterStateCount(Cluster.Status.SUCCESSFUL);
this.skipped = getClusterStateCount(Cluster.Status.SKIPPED);
// should only be called if "details" section of fromXContent is present (for ccsMinimizeRoundtrips)
this.ccsMinimizeRoundtrips = true;
this.ccsMinimizeRoundtrips = ccsMinimizeRoundtrips;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.ResolvedIndexExpressions;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -43,6 +44,8 @@ public final class SearchShardsRequest extends LegacyActionRequest implements In

private final String clusterAlias;

private ResolvedIndexExpressions resolvedIndexExpressions;

public SearchShardsRequest(
String[] indices,
IndicesOptions indicesOptions,
Expand Down Expand Up @@ -179,4 +182,14 @@ public int hashCode() {
result = 31 * result + Arrays.hashCode(indices);
return result;
}

@Override
public void setResolvedIndexExpressions(ResolvedIndexExpressions expressions) {
this.resolvedIndexExpressions = expressions;
}

@Override
public ResolvedIndexExpressions getResolvedIndexExpressions() {
return resolvedIndexExpressions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@

package org.elasticsearch.action.search;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ResolvedIndexExpressions;
import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsGroup;
import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsResponse;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.util.Maps;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.search.internal.AliasFilter;
Expand All @@ -35,28 +38,50 @@ public final class SearchShardsResponse extends ActionResponse {
private final Collection<SearchShardsGroup> groups;
private final Collection<DiscoveryNode> nodes;
private final Map<String, AliasFilter> aliasFilters;
private final ResolvedIndexExpressions resolvedIndexExpressions;
public static final TransportVersion SEARCH_SHARDS_RESOLVED_INDEX_EXPRESSIONS = TransportVersion.fromName(
"search_shards_resolved_index_expressions"
);

public SearchShardsResponse(
Collection<SearchShardsGroup> groups,
Collection<DiscoveryNode> nodes,
Map<String, AliasFilter> aliasFilters
Map<String, AliasFilter> aliasFilters,
@Nullable ResolvedIndexExpressions resolvedIndexExpressions
) {
this.groups = groups;
this.nodes = nodes;
this.aliasFilters = aliasFilters;
this.resolvedIndexExpressions = resolvedIndexExpressions;
}

public SearchShardsResponse(
Collection<SearchShardsGroup> groups,
Collection<DiscoveryNode> nodes,
Map<String, AliasFilter> aliasFilters
) {
this(groups, nodes, aliasFilters, null);
}

public SearchShardsResponse(StreamInput in) throws IOException {
this.groups = in.readCollectionAsList(SearchShardsGroup::new);
this.nodes = in.readCollectionAsList(DiscoveryNode::new);
this.aliasFilters = in.readMap(AliasFilter::readFrom);
if (in.getTransportVersion().supports(SEARCH_SHARDS_RESOLVED_INDEX_EXPRESSIONS)) {
this.resolvedIndexExpressions = in.readOptionalWriteable(ResolvedIndexExpressions::new);
} else {
this.resolvedIndexExpressions = null;
}
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeCollection(groups);
out.writeCollection(nodes);
out.writeMap(aliasFilters, StreamOutput::writeWriteable);
if (out.getTransportVersion().supports(SEARCH_SHARDS_RESOLVED_INDEX_EXPRESSIONS)) {
out.writeOptionalWriteable(resolvedIndexExpressions);
}
}

/**
Expand Down Expand Up @@ -114,4 +139,9 @@ static SearchShardsResponse fromLegacyResponse(ClusterSearchShardsResponse oldRe
public String toString() {
return "SearchShardsResponse{" + "groups=" + groups + ", nodes=" + nodes + ", aliasFilters=" + aliasFilters + '}';
}

@Nullable
public ResolvedIndexExpressions getResolvedIndexExpressions() {
return resolvedIndexExpressions;
}
}
Loading