Randomize numeric types in MLT test and apply mapping ahead of time.
This commit is contained in:
parent
8b9396b6da
commit
7c76819040
|
@ -29,6 +29,7 @@ import org.apache.lucene.util.TimeUnits;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ThreadLeakFilters(defaultFilters = true, filters = {ElasticsearchTestCase.ElasticSearchThreadFilter.class})
|
@ThreadLeakFilters(defaultFilters = true, filters = {ElasticsearchTestCase.ElasticSearchThreadFilter.class})
|
||||||
|
@ -70,4 +71,10 @@ public abstract class ElasticsearchTestCase extends AbstractRandomizedTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String[] numericTypes = new String[] {"byte", "short", "integer", "long"};
|
||||||
|
|
||||||
|
public static String randomNumericType(Random random) {
|
||||||
|
return numericTypes[random.nextInt(numericTypes.length)];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,13 @@ public class MoreLikeThisActionTests extends AbstractSharedClusterTest {
|
||||||
@Test
|
@Test
|
||||||
// See issue https://github.com/elasticsearch/elasticsearch/issues/3252
|
// See issue https://github.com/elasticsearch/elasticsearch/issues/3252
|
||||||
public void testNumericField() throws Exception {
|
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();
|
ensureGreen();
|
||||||
client().prepareIndex("test", "type", "1")
|
client().prepareIndex("test", "type", "1")
|
||||||
.setSource(jsonBuilder().startObject().field("string_value", "lucene index").field("int_value", 1).endObject())
|
.setSource(jsonBuilder().startObject().field("string_value", "lucene index").field("int_value", 1).endObject())
|
||||||
|
|
Loading…
Reference in New Issue