Modified test to make failures clearer

Added shard failure check when sorting on unmapped field, could be any SearchPhaseExecutionException otherwise (e.g. missing shards)
This commit is contained in:
Luca Cavanna 2013-08-01 17:07:12 +02:00
parent f2f70a415a
commit 60bddc28eb
1 changed files with 7 additions and 2 deletions

View File

@ -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))