1111import org .elasticsearch .action .datastreams .CreateDataStreamAction ;
1212import org .elasticsearch .cluster .block .ClusterBlockException ;
1313import org .elasticsearch .cluster .metadata .ComposableIndexTemplate ;
14+ import org .elasticsearch .cluster .metadata .IndexMetadata ;
15+ import org .elasticsearch .common .settings .Settings ;
1416import org .elasticsearch .common .util .CollectionUtils ;
1517import org .elasticsearch .datastreams .DataStreamsPlugin ;
1618import org .elasticsearch .index .IndexNotFoundException ;
@@ -108,12 +110,44 @@ public void testDoesNotResolveClosedIndex() {
108110 assertAcked (client ().admin ().indices ().prepareCreate ("index-1" ));
109111 indexRandom (true , "index-1" , 10 );
110112 assertAcked (client ().admin ().indices ().prepareClose ("index-1" ));
113+ assertAcked (client ().admin ().indices ().prepareCreate ("index-2" ));
114+ indexRandom (true , "index-2" , 15 );
111115
112116 expectThrows (
113117 ClusterBlockException .class ,
114118 containsString ("index [index-1] blocked by: [FORBIDDEN/4/index closed]" ),
115119 () -> run (syncEsqlQueryRequest ().query ("FROM index-1" ))
116120 );
121+ expectThrows (
122+ ClusterBlockException .class ,
123+ containsString ("index [index-1] blocked by: [FORBIDDEN/4/index closed]" ),
124+ () -> run (syncEsqlQueryRequest ().query ("FROM index-1,index-2" ))
125+ );
126+ try (var response = run (syncEsqlQueryRequest ().query ("FROM index-*" ))) {
127+ assertOk (response );
128+ assertResultCount (response , 15 );// only index-2 records match
129+ }
130+ }
131+
132+ public void testHiddenIndices () {
133+ assertAcked (client ().admin ().indices ().prepareCreate ("my-index-1" ));
134+ indexRandom (true , "my-index-1" , 10 );
135+ assertAcked (
136+ client ().admin ()
137+ .indices ()
138+ .prepareCreate (".hidden-index-1" )
139+ .setSettings (Settings .builder ().put (IndexMetadata .SETTING_INDEX_HIDDEN , true ))
140+ );
141+ indexRandom (true , ".hidden-index-1" , 15 );
142+
143+ try (var response = run (syncEsqlQueryRequest ().query ("FROM .hidden-index-1" ))) {
144+ assertOk (response );
145+ assertResultCount (response , 15 );
146+ }
147+ try (var response = run (syncEsqlQueryRequest ().query ("FROM *-index-1" ))) {
148+ assertOk (response );
149+ assertResultCount (response , 10 ); // only non hidden index matches
150+ }
117151 }
118152
119153 public void testPartialResolution () {
@@ -134,4 +168,14 @@ public void testPartialResolution() {
134168 private static void assertOk (EsqlQueryResponse response ) {
135169 assertThat (response .isPartial (), equalTo (false ));
136170 }
171+
172+ private static void assertResultCount (EsqlQueryResponse response , long rows ) {
173+ long count = 0 ;
174+ var iterator = response .column (0 );
175+ while (iterator .hasNext ()) {
176+ iterator .next ();
177+ count ++;
178+ }
179+ assertThat (count , equalTo (rows ));
180+ }
137181}
0 commit comments