Create mapping ahead of time and don't rely on index request in test
This commit is contained in:
parent
4e2b9ff2ad
commit
5b8ce393db
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue