From 892d7fca5099f636e6bfe21c6724bfeb5000a052 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Tue, 21 Jan 2025 15:04:38 -0500 Subject: [PATCH 1/3] take into account failure-store delimiter --- src/platform/packages/shared/kbn-es-query/src/utils.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/platform/packages/shared/kbn-es-query/src/utils.ts b/src/platform/packages/shared/kbn-es-query/src/utils.ts index 7ac29bd085da8..905a15e4efab2 100644 --- a/src/platform/packages/shared/kbn-es-query/src/utils.ts +++ b/src/platform/packages/shared/kbn-es-query/src/utils.ts @@ -42,7 +42,7 @@ export function getDataViewFieldSubtypeMulti(field: HasSubtype) { * The index name is assumed to be individual index (no commas) but can contain `-`, wildcards, * datemath, remote cluster name and any other syntax permissible in index expression component. * - * 2024/10/11 Implementation taken from https://github.com/smalyshev/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/transport/RemoteClusterAware.java + * 2025/01/21 Implementation taken from https://github.com/smalyshev/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/transport/RemoteClusterAware.java * * @param indexExpression */ @@ -52,6 +52,11 @@ export function isCCSRemoteIndexName(indexExpression: string): boolean { // Thus, whatever it is, this is definitely not a remote index. return false; } + + const idx = indexExpression.indexOf(':'); + // Check to make sure the remote cluster separator ':' isn't actually a selector separator '::' + const isSelector = indexExpression.startsWith('::', idx); + // Note remote index name also can not start with ':' - return indexExpression.indexOf(':') > 0; + return idx > 0 && !isSelector; } From 67fdf8d45fd0bef5422d24b996d129a5f90bb7f6 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Tue, 21 Jan 2025 16:59:19 -0500 Subject: [PATCH 2/3] add unit tests --- .../packages/shared/kbn-es-query/src/utils.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/platform/packages/shared/kbn-es-query/src/utils.test.ts b/src/platform/packages/shared/kbn-es-query/src/utils.test.ts index b7ac39e4c7eec..4e218bc32f290 100644 --- a/src/platform/packages/shared/kbn-es-query/src/utils.test.ts +++ b/src/platform/packages/shared/kbn-es-query/src/utils.test.ts @@ -30,5 +30,17 @@ describe('util tests', () => { it('should validate CCS pattern', () => { expect(isCCSRemoteIndexName('*:logstash-{now/d-2d}')).toBe(true); }); + + it('should not validate selctor with wildcard', () => { + expect(isCCSRemoteIndexName('my-data-stream::*')).toBe(false); + }); + + it('should not validate index name with selector', () => { + expect(isCCSRemoteIndexName('my-data-stream::failures')).toBe(false); + }); + + it('should not validate wildcard with selector', () => { + expect(isCCSRemoteIndexName('-logs-*::data')).toBe(false); + }); }); }); From 4e5afd1b2ff5c20da60ca1656a4ac004ff1cdc2a Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Wed, 22 Jan 2025 08:50:45 -0500 Subject: [PATCH 3/3] fix typo Co-authored-by: Lukas Olson --- src/platform/packages/shared/kbn-es-query/src/utils.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/packages/shared/kbn-es-query/src/utils.test.ts b/src/platform/packages/shared/kbn-es-query/src/utils.test.ts index 4e218bc32f290..e250286c9a1ee 100644 --- a/src/platform/packages/shared/kbn-es-query/src/utils.test.ts +++ b/src/platform/packages/shared/kbn-es-query/src/utils.test.ts @@ -31,7 +31,7 @@ describe('util tests', () => { expect(isCCSRemoteIndexName('*:logstash-{now/d-2d}')).toBe(true); }); - it('should not validate selctor with wildcard', () => { + it('should not validate selector with wildcard', () => { expect(isCCSRemoteIndexName('my-data-stream::*')).toBe(false); });