|
13 | 13 | import org.elasticsearch.cluster.metadata.MetadataCreateIndexService; |
14 | 14 | import org.elasticsearch.common.Strings; |
15 | 15 | import org.elasticsearch.indices.InvalidIndexNameException; |
| 16 | +import org.elasticsearch.transport.RemoteClusterService; |
16 | 17 | import org.elasticsearch.xpack.esql.core.util.Holder; |
17 | 18 | import org.elasticsearch.xpack.esql.parser.EsqlBaseParser.IdentifierContext; |
18 | 19 | import org.elasticsearch.xpack.esql.parser.EsqlBaseParser.IndexStringContext; |
@@ -82,12 +83,20 @@ public String visitIndexPattern(List<EsqlBaseParser.IndexPatternContext> ctx) { |
82 | 83 | if (clusterString == null) { |
83 | 84 | hasSeenStar.set(indexPattern.contains(WILDCARD) || hasSeenStar.get()); |
84 | 85 | validateIndexPattern(indexPattern, c, hasSeenStar.get()); |
| 86 | + } else { |
| 87 | + validateClusterString(clusterString, c); |
85 | 88 | } |
86 | 89 | patterns.add(clusterString != null ? clusterString + REMOTE_CLUSTER_INDEX_SEPARATOR + indexPattern : indexPattern); |
87 | 90 | }); |
88 | 91 | return Strings.collectionToDelimitedString(patterns, ","); |
89 | 92 | } |
90 | 93 |
|
| 94 | + protected static void validateClusterString(String clusterString, EsqlBaseParser.IndexPatternContext ctx) { |
| 95 | + if (clusterString.indexOf(RemoteClusterService.REMOTE_CLUSTER_INDEX_SEPARATOR) != -1) { |
| 96 | + throw new ParsingException(source(ctx), "cluster string [{}] must not contain ':'", clusterString); |
| 97 | + } |
| 98 | + } |
| 99 | + |
91 | 100 | private static void validateIndexPattern(String indexPattern, EsqlBaseParser.IndexPatternContext ctx, boolean hasSeenStar) { |
92 | 101 | // multiple index names can be in the same double quote, e.g. indexPattern = "idx1, *, -idx2" |
93 | 102 | String[] indices = indexPattern.split(","); |
|
0 commit comments