@@ -427,22 +427,6 @@ Index[] concreteIndices(Context context, String... indexExpressions) {
427
427
return concreteIndices .toArray (Index .EMPTY_ARRAY );
428
428
}
429
429
430
- private IndexNotFoundException notFoundException (String ... indexExpressions ) {
431
- IndexNotFoundException infe ;
432
- if (indexExpressions .length == 1 ) {
433
- if (indexExpressions [0 ].equals (Metadata .ALL )) {
434
- infe = new IndexNotFoundException ("no indices exist" , indexExpressions [0 ]);
435
- } else {
436
- infe = new IndexNotFoundException (indexExpressions [0 ]);
437
- }
438
- infe .setResources ("index_expression" , indexExpressions [0 ]);
439
- } else {
440
- infe = new IndexNotFoundException ((String ) null );
441
- infe .setResources ("index_expression" , indexExpressions );
442
- }
443
- return infe ;
444
- }
445
-
446
430
private void checkSystemIndexAccess (Context context , Set <Index > concreteIndices ) {
447
431
final Metadata metadata = context .getState ().metadata ();
448
432
final Predicate <String > systemIndexAccessPredicate = context .getSystemIndexAccessPredicate ().negate ();
@@ -489,6 +473,22 @@ private void checkSystemIndexAccess(Context context, Set<Index> concreteIndices)
489
473
}
490
474
}
491
475
476
+ private static IndexNotFoundException notFoundException (String ... indexExpressions ) {
477
+ IndexNotFoundException infe ;
478
+ if (indexExpressions != null && indexExpressions .length == 1 ) {
479
+ if (Metadata .ALL .equals (indexExpressions [0 ])) {
480
+ infe = new IndexNotFoundException ("no indices exist" , indexExpressions [0 ]);
481
+ } else {
482
+ infe = new IndexNotFoundException (indexExpressions [0 ]);
483
+ }
484
+ infe .setResources ("index_or_alias" , indexExpressions [0 ]);
485
+ } else {
486
+ infe = new IndexNotFoundException ((String ) null );
487
+ infe .setResources ("index_expression" , indexExpressions );
488
+ }
489
+ return infe ;
490
+ }
491
+
492
492
private static boolean shouldTrackConcreteIndex (Context context , IndicesOptions options , Index index ) {
493
493
if (context .systemIndexAccessLevel == SystemIndexAccessLevel .BACKWARDS_COMPATIBLE_ONLY
494
494
&& context .netNewSystemIndexPredicate .test (index .getName ())) {
@@ -1216,7 +1216,7 @@ private static Collection<String> innerResolve(Context context, List<String> exp
1216
1216
matchingOpenClosedNames .forEachOrdered (result ::add );
1217
1217
}
1218
1218
if (emptyWildcardExpansion .get ()) {
1219
- throw indexNotFoundException (expression );
1219
+ throw notFoundException (expression );
1220
1220
}
1221
1221
} else {
1222
1222
if (isExclusion ) {
@@ -1248,7 +1248,7 @@ private static Collection<String> innerResolve(Context context, List<String> exp
1248
1248
1249
1249
private static String validateAliasOrIndex (String expression ) {
1250
1250
if (Strings .isEmpty (expression )) {
1251
- throw indexNotFoundException (expression );
1251
+ throw notFoundException (expression );
1252
1252
}
1253
1253
// Expressions can not start with an underscore. This is reserved for APIs. If the check gets here, the API
1254
1254
// does not exist and the path is interpreted as an expression. If the expression begins with an underscore,
@@ -1265,23 +1265,17 @@ private static void ensureAliasOrIndexExists(Context context, String expression)
1265
1265
final IndicesOptions options = context .getOptions ();
1266
1266
IndexAbstraction indexAbstraction = context .getState ().getMetadata ().getIndicesLookup ().get (expression );
1267
1267
if (indexAbstraction == null ) {
1268
- throw indexNotFoundException (expression );
1268
+ throw notFoundException (expression );
1269
1269
}
1270
1270
// treat aliases as unavailable indices when ignoreAliases is set to true (e.g. delete index and update aliases api)
1271
1271
if (indexAbstraction .getType () == Type .ALIAS && options .ignoreAliases ()) {
1272
1272
throw aliasesNotSupportedException (expression );
1273
1273
}
1274
1274
if (indexAbstraction .isDataStreamRelated () && context .includeDataStreams () == false ) {
1275
- throw indexNotFoundException (expression );
1275
+ throw notFoundException (expression );
1276
1276
}
1277
1277
}
1278
1278
1279
- private static IndexNotFoundException indexNotFoundException (String expression ) {
1280
- IndexNotFoundException infe = new IndexNotFoundException (expression );
1281
- infe .setResources ("index_or_alias" , expression );
1282
- return infe ;
1283
- }
1284
-
1285
1279
private static IndexMetadata .State excludeState (IndicesOptions options ) {
1286
1280
final IndexMetadata .State excludeState ;
1287
1281
if (options .expandWildcardsOpen () && options .expandWildcardsClosed ()) {
0 commit comments