Skip to content

Commit

Permalink
Support wildcard/regex for indices param in _remotestore/_restore
Browse files Browse the repository at this point in the history
Signed-off-by: bansvaru <[email protected]>
  • Loading branch information
linuxpi committed Sep 6, 2023
1 parent 9b26bd9 commit f659908
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.apache.logging.log4j.Logger;
import org.opensearch.Version;
import org.opensearch.action.admin.cluster.remotestore.restore.RestoreRemoteStoreRequest;
import org.opensearch.action.support.IndicesOptions;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.ClusterStateUpdateTask;
import org.opensearch.cluster.block.ClusterBlocks;
Expand Down Expand Up @@ -48,6 +49,7 @@
import java.util.stream.Collectors;

import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REMOTE_STORE_ENABLED;
import static org.opensearch.snapshots.SnapshotUtils.filterIndices;

/**
* Service responsible for restoring index data from remote store
Expand Down Expand Up @@ -151,7 +153,12 @@ public RemoteRestoreResult restore(
throw new IllegalStateException("Unable to restore remote index metadata", e);
}
} else {
for (String indexName : indexNames) {
List<String> filteredIndices = filterIndices(
List.of(currentState.metadata().getConcreteAllIndices()),
indexNames,
IndicesOptions.fromOptions(true, true, true, true)
);
for (String indexName : filteredIndices) {
IndexMetadata indexMetadata = currentState.metadata().index(indexName);
if (indexMetadata == null) {
logger.warn("Index restore is not supported for non-existent index. Skipping: {}", indexName);
Expand Down

0 comments on commit f659908

Please sign in to comment.