@@ -259,14 +259,6 @@ private static void resolveSelectorsAndCollect(
259259 selectorString = IndexComponentSelector .DATA .getKey ();
260260 }
261261
262- // For the ::failures selector, only include the expression if the data stream actually has failure
263- // backing indices. A data stream can have failure store enabled in metadata (partially initialized)
264- // without any backing indices yet.
265- if (IndexComponentSelector .FAILURES .getKey ().equals (selectorString )
266- && abstraction .getFailureIndices (projectMetadata ).isEmpty ()) {
267- return ;
268- }
269-
270262 // A selector is always passed along as-is, it's validity for this kind of abstraction is tested later
271263 collect .add (IndexNameExpressionResolver .combineSelectorExpression (indexAbstraction , selectorString ));
272264 } else {
@@ -323,6 +315,7 @@ private static boolean isIndexVisible(
323315 || isHidden == false
324316 || indicesOptions .expandWildcardsHidden ()
325317 || isVisibleDueToImplicitHidden (expression , index );
318+ boolean isFailureStoreSelectorPresent = IndexComponentSelector .FAILURES .getKey ().equals (selectorString );
326319 if (indexAbstraction .getType () == IndexAbstraction .Type .ALIAS ) {
327320 // it's an alias, ignore expandWildcardsOpen and expandWildcardsClosed.
328321 // it's complicated to support those options with aliases pointing to multiple indices...
@@ -357,12 +350,9 @@ private static boolean isIndexVisible(
357350 }
358351 }
359352
360- if (isVisible && selectorString != null ) {
361- // Check if a selector was present, and if it is, check if this alias is applicable to it
362- IndexComponentSelector selector = IndexComponentSelector .getByKey (selectorString );
363- if (IndexComponentSelector .FAILURES .equals (selector )) {
364- isVisible = indexAbstraction .isDataStreamRelated ();
365- }
353+ // Check if a selector was present, and if it is, check if this alias is applicable to it
354+ if (isVisible && isFailureStoreSelectorPresent ) {
355+ isVisible = indexAbstraction .isDataStreamRelated ();
366356 }
367357 return isVisible ;
368358 }
@@ -372,9 +362,13 @@ private static boolean isIndexVisible(
372362 }
373363 if (indexAbstraction .isSystem ()) {
374364 return isSystemIndexVisible (resolver , indexAbstraction );
375- } else {
376- return isVisible ;
377365 }
366+ // A data stream with the ::failures selector is not visible if it has no failure backing indices.
367+ // A failure store can be enabled in metadata without any indices yet.
368+ if (isFailureStoreSelectorPresent && indexAbstraction .getFailureIndices (projectMetadata ).isEmpty ()) {
369+ return false ;
370+ }
371+ return isVisible ;
378372 }
379373 assert indexAbstraction .getIndices ().size () == 1 : "concrete index must point to a single index" ;
380374 if (isVisible == false ) {
@@ -397,8 +391,7 @@ private static boolean isIndexVisible(
397391 }
398392 if (selectorString != null && Regex .isMatchAllPattern (selectorString ) == false ) {
399393 // Check if a selector was present, and if it is, check if this index is applicable to it
400- IndexComponentSelector selector = IndexComponentSelector .getByKey (selectorString );
401- if (IndexComponentSelector .FAILURES .equals (selector )) {
394+ if (isFailureStoreSelectorPresent ) {
402395 return false ;
403396 }
404397 }
0 commit comments