@@ -164,25 +164,24 @@ private Map<String, Object> runEsql(RestEsqlTestCase.RequestObjectBuilder reques
164164 }
165165 }
166166
167- private <C , V > void assertResultMapForLike (
167+ private <C , V > void assertResultMapWithCapabilities (
168168 boolean includeCCSMetadata ,
169169 Map <String , Object > result ,
170170 C columns ,
171171 V values ,
172172 boolean remoteOnly ,
173- boolean requireLikeListCapability
173+ List < String > fullResultCapabilities
174174 ) throws IOException {
175- List <String > requiredCapabilities = new ArrayList <>(List .of ("like_on_index_fields" ));
176- if (requireLikeListCapability ) {
177- requiredCapabilities .add ("like_list_on_index_fields" );
178- }
179175 // the feature is completely supported if both local and remote clusters support it
180- boolean isSupported = capabilitiesSupportedNewAndOld ( requiredCapabilities );
181-
176+ // otherwise we expect a partial result, and will not check the data
177+ boolean isSupported = capabilitiesSupportedNewAndOld ( fullResultCapabilities );
182178 if (isSupported ) {
183179 assertResultMap (includeCCSMetadata , result , columns , values , remoteOnly );
184180 } else {
185- logger .info ("--> skipping data check for like index test, cluster does not support like index feature" );
181+ logger .info (
182+ "--> skipping data check for a test, cluster does not support all of [{}] capabilities" ,
183+ String .join ("," , fullResultCapabilities )
184+ );
186185 // just verify that we did not get a partial result
187186 var clusters = result .get ("_clusters" );
188187 var reason = "unexpected partial results" + (clusters != null ? ": _clusters=" + clusters : "" );
@@ -427,7 +426,7 @@ public void testLikeIndex() throws Exception {
427426 """ , includeCCSMetadata );
428427 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
429428 var values = List .of (List .of (remoteDocs .size (), REMOTE_CLUSTER_NAME + ":" + remoteIndex ));
430- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , false );
429+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List . of ( "like_on_index_fields" ) );
431430 }
432431
433432 public void testLikeIndexLegacySettingNoResults () throws Exception {
@@ -449,7 +448,7 @@ public void testLikeIndexLegacySettingNoResults() throws Exception {
449448 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
450449 // we expect empty result, since the setting is false
451450 var values = List .of ();
452- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , false );
451+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List . of ( "like_on_index_fields" ) );
453452 }
454453 }
455454
@@ -473,7 +472,7 @@ public void testLikeIndexLegacySettingResults() throws Exception {
473472 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
474473 // we expect results, since the setting is false, but there is : in the LIKE query
475474 var values = List .of (List .of (remoteDocs .size (), REMOTE_CLUSTER_NAME + ":" + remoteIndex ));
476- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , false );
475+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List . of ( "like_on_index_fields" ) );
477476 }
478477 }
479478
@@ -487,7 +486,7 @@ public void testNotLikeIndex() throws Exception {
487486 """ , includeCCSMetadata );
488487 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
489488 var values = List .of (List .of (localDocs .size (), localIndex ));
490- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , false );
489+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List . of ( "like_on_index_fields" ) );
491490 }
492491
493492 public void testLikeListIndex () throws Exception {
@@ -502,7 +501,14 @@ public void testLikeListIndex() throws Exception {
502501 """ , includeCCSMetadata );
503502 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
504503 var values = List .of (List .of (remoteDocs .size (), REMOTE_CLUSTER_NAME + ":" + remoteIndex ));
505- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , true );
504+ assertResultMapWithCapabilities (
505+ includeCCSMetadata ,
506+ result ,
507+ columns ,
508+ values ,
509+ false ,
510+ List .of ("like_on_index_fields" , "like_list_on_index_fields" )
511+ );
506512 }
507513
508514 public void testNotLikeListIndex () throws Exception {
@@ -516,7 +522,14 @@ public void testNotLikeListIndex() throws Exception {
516522 """ , includeCCSMetadata );
517523 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
518524 var values = List .of (List .of (localDocs .size (), localIndex ));
519- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , true );
525+ assertResultMapWithCapabilities (
526+ includeCCSMetadata ,
527+ result ,
528+ columns ,
529+ values ,
530+ false ,
531+ List .of ("like_on_index_fields" , "like_list_on_index_fields" )
532+ );
520533 }
521534
522535 public void testNotLikeListKeyword () throws Exception {
@@ -540,7 +553,14 @@ public void testNotLikeListKeyword() throws Exception {
540553 if (localCount > 0 ) {
541554 values .add (List .of (localCount , localIndex ));
542555 }
543- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , true );
556+ assertResultMapWithCapabilities (
557+ includeCCSMetadata ,
558+ result ,
559+ columns ,
560+ values ,
561+ false ,
562+ List .of ("like_on_index_fields" , "like_list_on_index_fields" )
563+ );
544564 }
545565
546566 public void testRLikeIndex () throws Exception {
@@ -553,7 +573,7 @@ public void testRLikeIndex() throws Exception {
553573 """ , includeCCSMetadata );
554574 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
555575 var values = List .of (List .of (remoteDocs .size (), REMOTE_CLUSTER_NAME + ":" + remoteIndex ));
556- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , false );
576+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List . of ( "like_on_index_fields" ) );
557577 }
558578
559579 public void testNotRLikeIndex () throws Exception {
@@ -566,7 +586,37 @@ public void testNotRLikeIndex() throws Exception {
566586 """ , includeCCSMetadata );
567587 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
568588 var values = List .of (List .of (localDocs .size (), localIndex ));
569- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , false );
589+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List .of ("like_on_index_fields" ));
590+ }
591+
592+ public void testRLikeListIndex () throws Exception {
593+ assumeTrue ("not supported" , capabilitiesSupportedNewAndOld (List .of ("rlike_with_list_of_patterns" )));
594+ boolean includeCCSMetadata = includeCCSMetadata ();
595+ Map <String , Object > result = run ("""
596+ FROM test-local-index,*:test-remote-index METADATA _index
597+ | WHERE _index RLIKE (".*remote.*", ".*not-exist.*")
598+ | STATS c = COUNT(*) BY _index
599+ | SORT _index ASC
600+ """ , includeCCSMetadata );
601+ var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
602+ var values = List .of (List .of (remoteDocs .size (), REMOTE_CLUSTER_NAME + ":" + remoteIndex ));
603+ // we depend on the code in like_on_index_fields to serialize an ExpressionQueryBuilder
604+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List .of ("like_on_index_fields" ));
605+ }
606+
607+ public void testNotRLikeListIndex () throws Exception {
608+ assumeTrue ("not supported" , capabilitiesSupportedNewAndOld (List .of ("rlike_with_list_of_patterns" )));
609+ boolean includeCCSMetadata = includeCCSMetadata ();
610+ Map <String , Object > result = run ("""
611+ FROM test-local-index,*:test-remote-index METADATA _index
612+ | WHERE _index NOT RLIKE (".*remote.*", ".*not-exist.*")
613+ | STATS c = COUNT(*) BY _index
614+ | SORT _index ASC
615+ """ , includeCCSMetadata );
616+ var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
617+ var values = List .of (List .of (localDocs .size (), localIndex ));
618+ // we depend on the code in like_on_index_fields to serialize an ExpressionQueryBuilder
619+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List .of ("like_on_index_fields" ));
570620 }
571621
572622 private RestClient remoteClusterClient () throws IOException {
0 commit comments