diff --git a/src/test/java/org/elasticsearch/test/integration/search/sort/SimpleSortTests.java b/src/test/java/org/elasticsearch/test/integration/search/sort/SimpleSortTests.java index 95c8e80a834..3d3a7624bfa 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/sort/SimpleSortTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/sort/SimpleSortTests.java @@ -813,13 +813,14 @@ public class SimpleSortTests extends AbstractSharedClusterTest { @Test public void testIgnoreUnmapped() throws Exception { createIndex("test"); + ensureYellow(); client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject() .field("id", "1") .field("i_value", -1) .field("d_value", -1.1) .endObject()).execute().actionGet(); - ensureYellow(); + logger.info("--> sort with an unmapped field, verify it fails"); try { SearchResponse result = client().prepareSearch() @@ -828,8 +829,12 @@ public class SimpleSortTests extends AbstractSharedClusterTest { .execute().actionGet(); assertThat("Expected exception but returned with", result, nullValue()); } catch (SearchPhaseExecutionException e) { + //we check that it's a parse failure rather than a different shard failure + for (ShardSearchFailure shardSearchFailure : e.shardFailures()) { + assertThat(shardSearchFailure.reason(), containsString("Parse Failure [No mapping found for [kkk] in order to sort on]")); + } } - ensureYellow(); + SearchResponse searchResponse = client().prepareSearch() .setQuery(matchAllQuery()) .addSort(SortBuilders.fieldSort("kkk").ignoreUnmapped(true))