diff --git a/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java b/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java index f60eea6d2eb..e488255e782 100644 --- a/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java +++ b/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java @@ -95,7 +95,7 @@ public class TransportExplainAction extends TransportShardSingleOperationAction< 0, new InternalSearchRequest().types(new String[]{request.type()}) .filteringAliases(request.filteringAlias()), - null, indexShard.searcher(), indexService, indexShard, + null, result.searcher(), indexService, indexShard, scriptService ); SearchContext.setCurrent(context); diff --git a/src/test/java/org/elasticsearch/test/integration/explain/ExplainActionTests.java b/src/test/java/org/elasticsearch/test/integration/explain/ExplainActionTests.java index 95f26e22d64..f07ac5b908b 100644 --- a/src/test/java/org/elasticsearch/test/integration/explain/ExplainActionTests.java +++ b/src/test/java/org/elasticsearch/test/integration/explain/ExplainActionTests.java @@ -24,6 +24,7 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.index.query.FilterBuilders; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -56,10 +57,13 @@ public class ExplainActionTests extends AbstractNodesTests { @Test public void testSimple() throws Exception { - client.admin().indices().prepareDelete("test").execute().actionGet(); + try { + client.admin().indices().prepareDelete("test").execute().actionGet(); + } catch (IndexMissingException e) {} client.admin().indices().prepareCreate("test").setSettings( ImmutableSettings.settingsBuilder().put("index.refresh_interval", -1) ).execute().actionGet(); + client.admin().cluster().prepareHealth("test").setWaitForGreenStatus().execute().actionGet(); client.prepareIndex("test", "test", "1") .setSource("field", "value1") @@ -116,9 +120,12 @@ public class ExplainActionTests extends AbstractNodesTests { @Test public void testExplainWithAlias() throws Exception { - client.admin().indices().prepareDelete().execute().actionGet(); + try { + client.admin().indices().prepareDelete("test").execute().actionGet(); + } catch (IndexMissingException e) {} client.admin().indices().prepareCreate("test") .execute().actionGet(); + client.admin().cluster().prepareHealth("test").setWaitForGreenStatus().execute().actionGet(); client.admin().indices().prepareAliases().addAlias("test", "alias1", FilterBuilders.termFilter("field2", "value2")) .execute().actionGet();