Handle indices=["_all"] when restoring a snapshot (#18025)
Setting indices=["_all"] when restoring a snapshot would throw an IndexNotFoundException instead of selecting all indices as in other APIs.
This commit is contained in:
parent
84a2b4e17e
commit
a5ab648fae
|
@ -19,6 +19,7 @@
|
|||
package org.elasticsearch.snapshots;
|
||||
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
|
||||
|
@ -43,7 +44,7 @@ public class SnapshotUtils {
|
|||
* @return filtered out indices
|
||||
*/
|
||||
public static List<String> filterIndices(List<String> availableIndices, String[] selectedIndices, IndicesOptions indicesOptions) {
|
||||
if (selectedIndices == null || selectedIndices.length == 0) {
|
||||
if (IndexNameExpressionResolver.isAllIndices(Arrays.asList(selectedIndices))) {
|
||||
return availableIndices;
|
||||
}
|
||||
Set<String> result = null;
|
||||
|
|
|
@ -32,6 +32,7 @@ public class SnapshotUtilsTests extends ESTestCase {
|
|||
public void testIndexNameFiltering() {
|
||||
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{}, new String[]{"foo", "bar", "baz"});
|
||||
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"*"}, new String[]{"foo", "bar", "baz"});
|
||||
assertIndexNameFiltering(new String[]{"foo", "bar", "baz"}, new String[]{"_all"}, 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"});
|
||||
|
|
Loading…
Reference in New Issue