Fix index selection for snapshot restore when non-existent indices are specified (#17715)
This commit is contained in:
parent
bf2483e4b3
commit
0b889f1a8f
|
@ -52,9 +52,10 @@ public class SnapshotUtils {
|
|||
boolean add = true;
|
||||
if (!indexOrPattern.isEmpty()) {
|
||||
if (availableIndices.contains(indexOrPattern)) {
|
||||
if (result != null) {
|
||||
result.add(indexOrPattern);
|
||||
if (result == null) {
|
||||
result = new HashSet<>();
|
||||
}
|
||||
result.add(indexOrPattern);
|
||||
continue;
|
||||
}
|
||||
if (indexOrPattern.charAt(0) == '+') {
|
||||
|
|
|
@ -34,6 +34,7 @@ public class SnapshotUtilsTests extends ESTestCase {
|
|||
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"*"}, new String[]{"foo", "bar", "baz"});
|
||||
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"foo", "bar", "baz"}, new String[]{"foo", "bar", "baz"});
|
||||
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"foo"}, new String[]{"foo"});
|
||||
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"baz", "not_available"}, new String[]{"baz"});
|
||||
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"ba*", "-bar", "-baz"}, new String[]{});
|
||||
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"-bar"}, new String[]{"foo", "baz"});
|
||||
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"-ba*"}, new String[]{"foo"});
|
||||
|
|
Loading…
Reference in New Issue