@@ -205,25 +205,24 @@ private Map<String, Object> runEsql(RestEsqlTestCase.RequestObjectBuilder reques
205205 }
206206 }
207207
208- private <C , V > void assertResultMapForLike (
208+ private <C , V > void assertResultMapWithCapabilities (
209209 boolean includeCCSMetadata ,
210210 Map <String , Object > result ,
211211 C columns ,
212212 V values ,
213213 boolean remoteOnly ,
214- boolean requireLikeListCapability
214+ List < String > fullResultCapabilities
215215 ) throws IOException {
216- List <String > requiredCapabilities = new ArrayList <>(List .of ("like_on_index_fields" ));
217- if (requireLikeListCapability ) {
218- requiredCapabilities .add ("like_list_on_index_fields" );
219- }
220216 // the feature is completely supported if both local and remote clusters support it
221- boolean isSupported = capabilitiesSupportedNewAndOld ( requiredCapabilities );
222-
217+ // otherwise we expect a partial result, and will not check the data
218+ boolean isSupported = capabilitiesSupportedNewAndOld ( fullResultCapabilities );
223219 if (isSupported ) {
224220 assertResultMap (includeCCSMetadata , result , columns , values , remoteOnly );
225221 } else {
226- logger .info ("--> skipping data check for like index test, cluster does not support like index feature" );
222+ logger .info (
223+ "--> skipping data check for a test, cluster does not support all of [{}] capabilities" ,
224+ String .join ("," , fullResultCapabilities )
225+ );
227226 // just verify that we did not get a partial result
228227 var clusters = result .get ("_clusters" );
229228 var reason = "unexpected partial results" + (clusters != null ? ": _clusters=" + clusters : "" );
@@ -526,7 +525,7 @@ public void testLikeIndex() throws Exception {
526525 """ , includeCCSMetadata );
527526 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
528527 var values = List .of (List .of (remoteDocs .size (), REMOTE_CLUSTER_NAME + ":" + remoteIndex ));
529- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , false );
528+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List . of ( "like_on_index_fields" ) );
530529 }
531530
532531 public void testLikeIndexLegacySettingNoResults () throws Exception {
@@ -548,7 +547,7 @@ public void testLikeIndexLegacySettingNoResults() throws Exception {
548547 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
549548 // we expect empty result, since the setting is false
550549 var values = List .of ();
551- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , false );
550+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List . of ( "like_on_index_fields" ) );
552551 }
553552 }
554553
@@ -572,7 +571,7 @@ public void testLikeIndexLegacySettingResults() throws Exception {
572571 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
573572 // we expect results, since the setting is false, but there is : in the LIKE query
574573 var values = List .of (List .of (remoteDocs .size (), REMOTE_CLUSTER_NAME + ":" + remoteIndex ));
575- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , false );
574+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List . of ( "like_on_index_fields" ) );
576575 }
577576 }
578577
@@ -586,7 +585,7 @@ public void testNotLikeIndex() throws Exception {
586585 """ , includeCCSMetadata );
587586 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
588587 var values = List .of (List .of (localDocs .size (), localIndex ));
589- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , false );
588+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List . of ( "like_on_index_fields" ) );
590589 }
591590
592591 public void testLikeListIndex () throws Exception {
@@ -601,7 +600,14 @@ public void testLikeListIndex() throws Exception {
601600 """ , includeCCSMetadata );
602601 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
603602 var values = List .of (List .of (remoteDocs .size (), REMOTE_CLUSTER_NAME + ":" + remoteIndex ));
604- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , true );
603+ assertResultMapWithCapabilities (
604+ includeCCSMetadata ,
605+ result ,
606+ columns ,
607+ values ,
608+ false ,
609+ List .of ("like_on_index_fields" , "like_list_on_index_fields" )
610+ );
605611 }
606612
607613 public void testNotLikeListIndex () throws Exception {
@@ -615,7 +621,14 @@ public void testNotLikeListIndex() throws Exception {
615621 """ , includeCCSMetadata );
616622 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
617623 var values = List .of (List .of (localDocs .size (), localIndex ));
618- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , true );
624+ assertResultMapWithCapabilities (
625+ includeCCSMetadata ,
626+ result ,
627+ columns ,
628+ values ,
629+ false ,
630+ List .of ("like_on_index_fields" , "like_list_on_index_fields" )
631+ );
619632 }
620633
621634 public void testNotLikeListKeyword () throws Exception {
@@ -639,7 +652,14 @@ public void testNotLikeListKeyword() throws Exception {
639652 if (localCount > 0 ) {
640653 values .add (List .of (localCount , localIndex ));
641654 }
642- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , true );
655+ assertResultMapWithCapabilities (
656+ includeCCSMetadata ,
657+ result ,
658+ columns ,
659+ values ,
660+ false ,
661+ List .of ("like_on_index_fields" , "like_list_on_index_fields" )
662+ );
643663 }
644664
645665 public void testRLikeIndex () throws Exception {
@@ -652,7 +672,7 @@ public void testRLikeIndex() throws Exception {
652672 """ , includeCCSMetadata );
653673 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
654674 var values = List .of (List .of (remoteDocs .size (), REMOTE_CLUSTER_NAME + ":" + remoteIndex ));
655- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , false );
675+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List . of ( "like_on_index_fields" ) );
656676 }
657677
658678 public void testNotRLikeIndex () throws Exception {
@@ -665,7 +685,37 @@ public void testNotRLikeIndex() throws Exception {
665685 """ , includeCCSMetadata );
666686 var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
667687 var values = List .of (List .of (localDocs .size (), localIndex ));
668- assertResultMapForLike (includeCCSMetadata , result , columns , values , false , false );
688+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List .of ("like_on_index_fields" ));
689+ }
690+
691+ public void testRLikeListIndex () throws Exception {
692+ assumeTrue ("not supported" , capabilitiesSupportedNewAndOld (List .of ("rlike_with_list_of_patterns" )));
693+ boolean includeCCSMetadata = includeCCSMetadata ();
694+ Map <String , Object > result = run ("""
695+ FROM test-local-index,*:test-remote-index METADATA _index
696+ | WHERE _index RLIKE (".*remote.*", ".*not-exist.*")
697+ | STATS c = COUNT(*) BY _index
698+ | SORT _index ASC
699+ """ , includeCCSMetadata );
700+ var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
701+ var values = List .of (List .of (remoteDocs .size (), REMOTE_CLUSTER_NAME + ":" + remoteIndex ));
702+ // we depend on the code in like_on_index_fields to serialize an ExpressionQueryBuilder
703+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List .of ("like_on_index_fields" ));
704+ }
705+
706+ public void testNotRLikeListIndex () throws Exception {
707+ assumeTrue ("not supported" , capabilitiesSupportedNewAndOld (List .of ("rlike_with_list_of_patterns" )));
708+ boolean includeCCSMetadata = includeCCSMetadata ();
709+ Map <String , Object > result = run ("""
710+ FROM test-local-index,*:test-remote-index METADATA _index
711+ | WHERE _index NOT RLIKE (".*remote.*", ".*not-exist.*")
712+ | STATS c = COUNT(*) BY _index
713+ | SORT _index ASC
714+ """ , includeCCSMetadata );
715+ var columns = List .of (Map .of ("name" , "c" , "type" , "long" ), Map .of ("name" , "_index" , "type" , "keyword" ));
716+ var values = List .of (List .of (localDocs .size (), localIndex ));
717+ // we depend on the code in like_on_index_fields to serialize an ExpressionQueryBuilder
718+ assertResultMapWithCapabilities (includeCCSMetadata , result , columns , values , false , List .of ("like_on_index_fields" ));
669719 }
670720
671721 private RestClient remoteClusterClient () throws IOException {
0 commit comments