From 5b8ce393dbd790ee1b7f6dc5200fdb31bf3d3c8b Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 8 Aug 2013 17:28:59 +0200 Subject: [PATCH] Create mapping ahead of time and don't rely on index request in test --- .../suggest/CompletionSuggestSearchTests.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/elasticsearch/test/integration/search/suggest/CompletionSuggestSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/suggest/CompletionSuggestSearchTests.java index fe9756c6548..e35946bc793 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/suggest/CompletionSuggestSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/suggest/CompletionSuggestSearchTests.java @@ -26,6 +26,7 @@ import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.suggest.SuggestResponse; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.index.mapper.MapperException; import org.elasticsearch.search.suggest.Suggest; @@ -53,7 +54,7 @@ public class CompletionSuggestSearchTests extends AbstractSharedClusterTest { private static final String INDEX = "test"; private static final String TYPE = "testType"; private static final String FIELD = "testField"; - + @Test public void testSimple() throws Exception{ createIndexAndMapping(); @@ -289,10 +290,18 @@ public class CompletionSuggestSearchTests extends AbstractSharedClusterTest { @Test public void testThatUpgradeToMultiFieldWorks() throws Exception { - client().admin().indices().prepareDelete().get(); Settings.Builder settingsBuilder = createDefaultSettings(); - - client().admin().indices().prepareCreate(INDEX).setSettings(settingsBuilder).get(); + final XContentBuilder mapping = jsonBuilder() + .startObject() + .startObject(TYPE) + .startObject("properties") + .startObject(FIELD) + .field("type", "string") + .endObject() + .endObject() + .endObject() + .endObject(); + client().admin().indices().prepareCreate(INDEX).addMapping(TYPE, mapping).setSettings(settingsBuilder).get(); ensureYellow(); client().prepareIndex(INDEX, TYPE, "1").setRefresh(true).setSource(jsonBuilder().startObject().field(FIELD, "Foo Fighters").endObject()).get();