From 2a588dc1f109022331ae43959ac8e2e46ee69168 Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Thu, 4 Apr 2013 15:53:50 -0400 Subject: [PATCH] Fix IndexMissingException in get template request Fixes #2873 --- .../admin/cluster/state/ClusterStateRequest.java | 7 +++++++ .../cluster/state/TransportClusterStateAction.java | 12 +++++++----- .../template/get/RestGetIndexTemplateAction.java | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java index 382070e0489..df5128be98b 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java @@ -32,6 +32,8 @@ import java.io.IOException; */ public class ClusterStateRequest extends MasterNodeOperationRequest { + public final static String NONE = "_na"; + private boolean filterRoutingTable = false; private boolean filterNodes = false; @@ -104,6 +106,11 @@ public class ClusterStateRequest extends MasterNodeOperationRequest 0) { - String[] indices = currentState.metaData().concreteIndicesIgnoreMissing(request.filteredIndices()); - for (String filteredIndex : indices) { - IndexMetaData indexMetaData = currentState.metaData().index(filteredIndex); - if (indexMetaData != null) { - mdBuilder.put(indexMetaData, false); + if (!(request.filteredIndices().length == 1 && ClusterStateRequest.NONE.equals(request.filteredIndices()[0]))) { + String[] indices = currentState.metaData().concreteIndicesIgnoreMissing(request.filteredIndices()); + for (String filteredIndex : indices) { + IndexMetaData indexMetaData = currentState.metaData().index(filteredIndex); + if (indexMetaData != null) { + mdBuilder.put(indexMetaData, false); + } } } } diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/template/get/RestGetIndexTemplateAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/template/get/RestGetIndexTemplateAction.java index cdbd5c5f5ec..4b1b6acad7b 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/template/get/RestGetIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/template/get/RestGetIndexTemplateAction.java @@ -64,7 +64,7 @@ public class RestGetIndexTemplateAction extends BaseRestHandler { .filterRoutingTable(true) .filterNodes(true) .filteredIndexTemplates(request.param("name")) - .filteredIndices("_na"); + .filterOutIndices(); clusterStateRequest.listenerThreaded(false);