diff --git a/src/test/java/org/elasticsearch/test/integration/ElasticsearchTestCase.java b/src/test/java/org/elasticsearch/test/integration/ElasticsearchTestCase.java index 5729a849d3f..21f1066b1db 100644 --- a/src/test/java/org/elasticsearch/test/integration/ElasticsearchTestCase.java +++ b/src/test/java/org/elasticsearch/test/integration/ElasticsearchTestCase.java @@ -29,6 +29,7 @@ import org.apache.lucene.util.TimeUnits; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; +import java.util.Random; import java.util.concurrent.TimeUnit; @ThreadLeakFilters(defaultFilters = true, filters = {ElasticsearchTestCase.ElasticSearchThreadFilter.class}) @@ -69,5 +70,11 @@ public abstract class ElasticsearchTestCase extends AbstractRandomizedTest { Thread.sleep(Math.max(timeInMillis, 0)); } + + private static final String[] numericTypes = new String[] {"byte", "short", "integer", "long"}; + + public static String randomNumericType(Random random) { + return numericTypes[random.nextInt(numericTypes.length)]; + } } diff --git a/src/test/java/org/elasticsearch/test/integration/mlt/MoreLikeThisActionTests.java b/src/test/java/org/elasticsearch/test/integration/mlt/MoreLikeThisActionTests.java index 332d3d70a6b..fc3caec1b44 100644 --- a/src/test/java/org/elasticsearch/test/integration/mlt/MoreLikeThisActionTests.java +++ b/src/test/java/org/elasticsearch/test/integration/mlt/MoreLikeThisActionTests.java @@ -179,7 +179,13 @@ public class MoreLikeThisActionTests extends AbstractSharedClusterTest { @Test // See issue https://github.com/elasticsearch/elasticsearch/issues/3252 public void testNumericField() throws Exception { - prepareCreate("test").execute().actionGet(); + prepareCreate("test").addMapping("type", jsonBuilder() + .startObject().startObject("type") + .startObject("properties") + .startObject("int_value").field("type", randomNumericType(getRandom())).endObject() + .startObject("string_value").field("type", "string").endObject() + .endObject() + .endObject().endObject()).execute().actionGet(); ensureGreen(); client().prepareIndex("test", "type", "1") .setSource(jsonBuilder().startObject().field("string_value", "lucene index").field("int_value", 1).endObject())