diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptMappedFieldType.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldType.java similarity index 98% rename from x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptMappedFieldType.java rename to x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldType.java index cdfee2cd92b..831d44549e5 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptMappedFieldType.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldType.java @@ -32,11 +32,11 @@ import static org.elasticsearch.search.SearchService.ALLOW_EXPENSIVE_QUERIES; /** * Abstract base {@linkplain MappedFieldType} for scripted fields. */ -abstract class AbstractScriptMappedFieldType extends MappedFieldType { +abstract class AbstractScriptFieldType extends MappedFieldType { protected final Script script; private final TriFunction, SearchLookup, LeafFactory> factory; - AbstractScriptMappedFieldType( + AbstractScriptFieldType( String name, Script script, TriFunction, SearchLookup, LeafFactory> factory, diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptMappedFieldType.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptFieldType.java similarity index 96% rename from x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptMappedFieldType.java rename to x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptFieldType.java index 68b222c9ee0..383ffb8a46e 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptMappedFieldType.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptFieldType.java @@ -27,8 +27,8 @@ import java.util.List; import java.util.Map; import java.util.function.Supplier; -public class BooleanScriptMappedFieldType extends AbstractScriptMappedFieldType { - BooleanScriptMappedFieldType(String name, Script script, BooleanFieldScript.Factory scriptFactory, Map meta) { +public class BooleanScriptFieldType extends AbstractScriptFieldType { + BooleanScriptFieldType(String name, Script script, BooleanFieldScript.Factory scriptFactory, Map meta) { super(name, script, scriptFactory::newFactory, meta); } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptMappedFieldType.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptFieldType.java similarity index 97% rename from x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptMappedFieldType.java rename to x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptFieldType.java index ccb0d3461df..c69148fe437 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptMappedFieldType.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptFieldType.java @@ -35,10 +35,10 @@ import java.util.Locale; import java.util.Map; import java.util.function.Supplier; -public class DateScriptMappedFieldType extends AbstractScriptMappedFieldType { +public class DateScriptFieldType extends AbstractScriptFieldType { private final DateFormatter dateTimeFormatter; - DateScriptMappedFieldType( + DateScriptFieldType( String name, Script script, DateFieldScript.Factory scriptFactory, diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptMappedFieldType.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptFieldType.java similarity index 94% rename from x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptMappedFieldType.java rename to x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptFieldType.java index 480d6fea2de..b1a7d2e198d 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptMappedFieldType.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptFieldType.java @@ -27,8 +27,8 @@ import java.util.List; import java.util.Map; import java.util.function.Supplier; -public class DoubleScriptMappedFieldType extends AbstractScriptMappedFieldType { - DoubleScriptMappedFieldType(String name, Script script, DoubleFieldScript.Factory scriptFactory, Map meta) { +public class DoubleScriptFieldType extends AbstractScriptFieldType { + DoubleScriptFieldType(String name, Script script, DoubleFieldScript.Factory scriptFactory, Map meta) { super(name, script, scriptFactory::newFactory, meta); } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptMappedFieldType.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptFieldType.java similarity index 96% rename from x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptMappedFieldType.java rename to x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptFieldType.java index a8793026703..c4c01883f1b 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptMappedFieldType.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptFieldType.java @@ -36,8 +36,8 @@ import java.util.Locale; import java.util.Map; import java.util.function.Supplier; -public final class IpScriptMappedFieldType extends AbstractScriptMappedFieldType { - IpScriptMappedFieldType(String name, Script script, IpFieldScript.Factory scriptFactory, Map meta) { +public final class IpScriptFieldType extends AbstractScriptFieldType { + IpScriptFieldType(String name, Script script, IpFieldScript.Factory scriptFactory, Map meta) { super(name, script, scriptFactory::newFactory, meta); } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptMappedFieldType.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptFieldType.java similarity index 96% rename from x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptMappedFieldType.java rename to x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptFieldType.java index 24dc33fef75..abb3edf4b5c 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptMappedFieldType.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptFieldType.java @@ -35,8 +35,8 @@ import java.util.function.Supplier; import static java.util.stream.Collectors.toSet; -public final class KeywordScriptMappedFieldType extends AbstractScriptMappedFieldType { - KeywordScriptMappedFieldType(String name, Script script, StringFieldScript.Factory scriptFactory, Map meta) { +public final class KeywordScriptFieldType extends AbstractScriptFieldType { + KeywordScriptFieldType(String name, Script script, StringFieldScript.Factory scriptFactory, Map meta) { super(name, script, scriptFactory::newFactory, meta); } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptMappedFieldType.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptFieldType.java similarity index 94% rename from x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptMappedFieldType.java rename to x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptFieldType.java index 2e2c202ad11..fcb7c7ca6d6 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptMappedFieldType.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptFieldType.java @@ -27,8 +27,8 @@ import java.util.List; import java.util.Map; import java.util.function.Supplier; -public class LongScriptMappedFieldType extends AbstractScriptMappedFieldType { - LongScriptMappedFieldType(String name, Script script, LongFieldScript.Factory scriptFactory, Map meta) { +public class LongScriptFieldType extends AbstractScriptFieldType { + LongScriptFieldType(String name, Script script, LongFieldScript.Factory scriptFactory, Map meta) { super(name, script, scriptFactory::newFactory, meta); } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/RuntimeFieldMapper.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/RuntimeFieldMapper.java index c375df1f799..fc5c3f86025 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/RuntimeFieldMapper.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/RuntimeFieldMapper.java @@ -47,7 +47,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper { protected RuntimeFieldMapper( String simpleName, - AbstractScriptMappedFieldType mappedFieldType, + AbstractScriptFieldType mappedFieldType, MultiFields multiFields, CopyTo copyTo, String runtimeType, @@ -60,14 +60,6 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper { this.scriptCompiler = scriptCompiler; } - String runtimeType() { - return runtimeType; - } - - Script script() { - return script; - } - @Override public ParametrizedFieldMapper.Builder getMergeBuilder() { return new RuntimeFieldMapper.Builder(simpleName(), scriptCompiler).init(this); @@ -90,11 +82,11 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper { public static class Builder extends ParametrizedFieldMapper.Builder { - static final Map>> FIELD_TYPE_RESOLVER = + static final Map>> FIELD_TYPE_RESOLVER = org.elasticsearch.common.collect.Map.of(BooleanFieldMapper.CONTENT_TYPE, (builder, context) -> { builder.formatAndLocaleNotSupported(); BooleanFieldScript.Factory factory = builder.scriptCompiler.compile(builder.script.getValue(), BooleanFieldScript.CONTEXT); - return new BooleanScriptMappedFieldType( + return new BooleanScriptFieldType( builder.buildFullName(context), builder.script.getValue(), factory, @@ -111,7 +103,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper { locale = Locale.ROOT; } DateFormatter dateTimeFormatter = DateFormatter.forPattern(format).withLocale(locale); - return new DateScriptMappedFieldType( + return new DateScriptFieldType( builder.buildFullName(context), builder.script.getValue(), factory, @@ -121,7 +113,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper { }, NumberType.DOUBLE.typeName(), (builder, context) -> { builder.formatAndLocaleNotSupported(); DoubleFieldScript.Factory factory = builder.scriptCompiler.compile(builder.script.getValue(), DoubleFieldScript.CONTEXT); - return new DoubleScriptMappedFieldType( + return new DoubleScriptFieldType( builder.buildFullName(context), builder.script.getValue(), factory, @@ -130,16 +122,11 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper { }, IpFieldMapper.CONTENT_TYPE, (builder, context) -> { builder.formatAndLocaleNotSupported(); IpFieldScript.Factory factory = builder.scriptCompiler.compile(builder.script.getValue(), IpFieldScript.CONTEXT); - return new IpScriptMappedFieldType( - builder.buildFullName(context), - builder.script.getValue(), - factory, - builder.meta.getValue() - ); + return new IpScriptFieldType(builder.buildFullName(context), builder.script.getValue(), factory, builder.meta.getValue()); }, KeywordFieldMapper.CONTENT_TYPE, (builder, context) -> { builder.formatAndLocaleNotSupported(); StringFieldScript.Factory factory = builder.scriptCompiler.compile(builder.script.getValue(), StringFieldScript.CONTEXT); - return new KeywordScriptMappedFieldType( + return new KeywordScriptFieldType( builder.buildFullName(context), builder.script.getValue(), factory, @@ -148,12 +135,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper { }, NumberType.LONG.typeName(), (builder, context) -> { builder.formatAndLocaleNotSupported(); LongFieldScript.Factory factory = builder.scriptCompiler.compile(builder.script.getValue(), LongFieldScript.CONTEXT); - return new LongScriptMappedFieldType( - builder.buildFullName(context), - builder.script.getValue(), - factory, - builder.meta.getValue() - ); + return new LongScriptFieldType(builder.buildFullName(context), builder.script.getValue(), factory, builder.meta.getValue()); }); private static RuntimeFieldMapper toType(FieldMapper in) { @@ -185,7 +167,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper { private final Parameter format = Parameter.stringParam( "format", true, - mapper -> ((AbstractScriptMappedFieldType) mapper.fieldType()).format(), + mapper -> ((AbstractScriptFieldType) mapper.fieldType()).format(), null ).setSerializer((b, n, v) -> { if (v != null && false == v.equals(DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.pattern())) { @@ -197,7 +179,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper { true, () -> null, (n, c, o) -> o == null ? null : LocaleUtils.parse(o.toString()), - mapper -> ((AbstractScriptMappedFieldType) mapper.fieldType()).formatLocale() + mapper -> ((AbstractScriptFieldType) mapper.fieldType()).formatLocale() ).setSerializer((b, n, v) -> { if (v != null && false == v.equals(Locale.ROOT)) { b.field(n, v.toString()); @@ -218,7 +200,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper { @Override public RuntimeFieldMapper build(BuilderContext context) { - BiFunction> fieldTypeResolver = Builder.FIELD_TYPE_RESOLVER.get( + BiFunction> fieldTypeResolver = Builder.FIELD_TYPE_RESOLVER.get( runtimeType.getValue() ); if (fieldTypeResolver == null) { diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractNonTextScriptMappedFieldTypeTestCase.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractNonTextScriptFieldTypeTestCase.java similarity index 95% rename from x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractNonTextScriptMappedFieldTypeTestCase.java rename to x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractNonTextScriptFieldTypeTestCase.java index f14924b41a8..ddb044bb32f 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractNonTextScriptMappedFieldTypeTestCase.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractNonTextScriptFieldTypeTestCase.java @@ -13,7 +13,7 @@ import java.io.IOException; import static org.hamcrest.Matchers.equalTo; -abstract class AbstractNonTextScriptMappedFieldTypeTestCase extends AbstractScriptMappedFieldTypeTestCase { +abstract class AbstractNonTextScriptFieldTypeTestCase extends AbstractScriptFieldTypeTestCase { public void testFuzzyQueryIsError() throws IOException { assertQueryOnlyOnTextAndKeyword( "fuzzy", diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptMappedFieldTypeTestCase.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldTypeTestCase.java similarity index 98% rename from x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptMappedFieldTypeTestCase.java rename to x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldTypeTestCase.java index 18b8f93b3b5..bf42f16137c 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptMappedFieldTypeTestCase.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractScriptFieldTypeTestCase.java @@ -25,7 +25,7 @@ import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -abstract class AbstractScriptMappedFieldTypeTestCase extends ESTestCase { +abstract class AbstractScriptFieldTypeTestCase extends ESTestCase { protected abstract MappedFieldType simpleMappedFieldType() throws IOException; protected abstract MappedFieldType loopFieldType() throws IOException; diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptMappedFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptFieldTypeTests.java similarity index 97% rename from x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptMappedFieldTypeTests.java rename to x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptFieldTypeTests.java index 29d2653346f..5623f029588 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptMappedFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/BooleanScriptFieldTypeTests.java @@ -66,7 +66,7 @@ import static org.hamcrest.Matchers.instanceOf; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class BooleanScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedFieldTypeTestCase { +public class BooleanScriptFieldTypeTests extends AbstractNonTextScriptFieldTypeTestCase { @Override public void testDocValues() throws IOException { try (Directory directory = newDirectory(); RandomIndexWriter iw = new RandomIndexWriter(random(), directory)) { @@ -75,7 +75,7 @@ public class BooleanScriptMappedFieldTypeTests extends AbstractNonTextScriptMapp List results = new ArrayList<>(); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - BooleanScriptMappedFieldType ft = simpleMappedFieldType(); + BooleanScriptFieldType ft = simpleMappedFieldType(); BooleanScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null, null); searcher.search(new MatchAllDocsQuery(), new Collector() { @Override @@ -436,7 +436,7 @@ public class BooleanScriptMappedFieldTypeTests extends AbstractNonTextScriptMapp } @Override - protected BooleanScriptMappedFieldType simpleMappedFieldType() throws IOException { + protected BooleanScriptFieldType simpleMappedFieldType() throws IOException { return build("read_foo", org.elasticsearch.common.collect.Map.of()); } @@ -450,11 +450,11 @@ public class BooleanScriptMappedFieldTypeTests extends AbstractNonTextScriptMapp return "boolean"; } - private static BooleanScriptMappedFieldType build(String code, Map params) throws IOException { + private static BooleanScriptFieldType build(String code, Map params) throws IOException { return build(new Script(ScriptType.INLINE, "test", code, params)); } - private static BooleanScriptMappedFieldType build(Script script) throws IOException { + private static BooleanScriptFieldType build(Script script) throws IOException { ScriptPlugin scriptPlugin = new ScriptPlugin() { @Override public ScriptEngine getScriptEngine(Settings settings, Collection> contexts) { @@ -520,7 +520,7 @@ public class BooleanScriptMappedFieldTypeTests extends AbstractNonTextScriptMapp ); try (ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptModule.engines, scriptModule.contexts)) { BooleanFieldScript.Factory factory = scriptService.compile(script, BooleanFieldScript.CONTEXT); - return new BooleanScriptMappedFieldType("test", script, factory, emptyMap()); + return new BooleanScriptFieldType("test", script, factory, emptyMap()); } } } diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptMappedFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptFieldTypeTests.java similarity index 96% rename from x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptMappedFieldTypeTests.java rename to x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptFieldTypeTests.java index 861076b7c1d..ca29e10c226 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptMappedFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DateScriptFieldTypeTests.java @@ -64,7 +64,7 @@ import static org.hamcrest.Matchers.closeTo; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -public class DateScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedFieldTypeTestCase { +public class DateScriptFieldTypeTests extends AbstractNonTextScriptFieldTypeTestCase { public void testFormat() throws IOException { assertThat(simpleMappedFieldType().docValueFormat("date", null).format(1595432181354L), equalTo("2020-07-22")); assertThat( @@ -84,7 +84,7 @@ public class DateScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedF public void testFormatDuel() throws IOException { DateFormatter formatter = DateFormatter.forPattern(randomDateFormatterPattern()).withLocale(randomLocale(random())); - DateScriptMappedFieldType scripted = build( + DateScriptFieldType scripted = build( new Script(ScriptType.INLINE, "test", "read_timestamp", org.elasticsearch.common.collect.Map.of()), formatter ); @@ -114,7 +114,7 @@ public class DateScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedF List results = new ArrayList<>(); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - DateScriptMappedFieldType ft = build("add_days", org.elasticsearch.common.collect.Map.of("days", 1)); + DateScriptFieldType ft = build("add_days", org.elasticsearch.common.collect.Map.of("days", 1)); DateScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null, null); searcher.search(new MatchAllDocsQuery(), new Collector() { @Override @@ -347,7 +347,7 @@ public class DateScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedF @Override protected Query randomRangeQuery(MappedFieldType ft, QueryShardContext ctx) { long d1 = randomDate(); - long d2 = randomValueOtherThan(d1, DateScriptMappedFieldTypeTests::randomDate); + long d2 = randomValueOtherThan(d1, DateScriptFieldTypeTests::randomDate); if (d1 > d2) { long backup = d2; d2 = d1; @@ -454,11 +454,11 @@ public class DateScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedF @Override protected Query randomTermsQuery(MappedFieldType ft, QueryShardContext ctx) { - return ft.termsQuery(randomList(1, 100, DateScriptMappedFieldTypeTests::randomDate), ctx); + return ft.termsQuery(randomList(1, 100, DateScriptFieldTypeTests::randomDate), ctx); } @Override - protected DateScriptMappedFieldType simpleMappedFieldType() throws IOException { + protected DateScriptFieldType simpleMappedFieldType() throws IOException { return build("read_timestamp"); } @@ -467,7 +467,7 @@ public class DateScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedF return build("loop"); } - private DateScriptMappedFieldType coolFormattedFieldType() throws IOException { + private DateScriptFieldType coolFormattedFieldType() throws IOException { return build(simpleMappedFieldType().script, DateFormatter.forPattern("yyyy-MM-dd(-■_■)HH:mm:ss.SSSz||epoch_millis")); } @@ -476,15 +476,15 @@ public class DateScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedF return "date"; } - private static DateScriptMappedFieldType build(String code) throws IOException { + private static DateScriptFieldType build(String code) throws IOException { return build(code, org.elasticsearch.common.collect.Map.of()); } - private static DateScriptMappedFieldType build(String code, Map params) throws IOException { + private static DateScriptFieldType build(String code, Map params) throws IOException { return build(new Script(ScriptType.INLINE, "test", code, params), DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER); } - private static DateScriptMappedFieldType build(Script script, DateFormatter dateTimeFormatter) throws IOException { + private static DateScriptFieldType build(Script script, DateFormatter dateTimeFormatter) throws IOException { ScriptPlugin scriptPlugin = new ScriptPlugin() { @Override public ScriptEngine getScriptEngine(Settings settings, Collection> contexts) { @@ -566,7 +566,7 @@ public class DateScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedF ); try (ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptModule.engines, scriptModule.contexts)) { DateFieldScript.Factory factory = scriptService.compile(script, DateFieldScript.CONTEXT); - return new DateScriptMappedFieldType("test", script, factory, dateTimeFormatter, emptyMap()); + return new DateScriptFieldType("test", script, factory, dateTimeFormatter, emptyMap()); } } diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptMappedFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptFieldTypeTests.java similarity index 96% rename from x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptMappedFieldTypeTests.java rename to x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptFieldTypeTests.java index 7e538b83b5f..d8ffa00e10b 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptMappedFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/DoubleScriptFieldTypeTests.java @@ -51,7 +51,7 @@ import java.util.Set; import static java.util.Collections.emptyMap; import static org.hamcrest.Matchers.equalTo; -public class DoubleScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedFieldTypeTestCase { +public class DoubleScriptFieldTypeTests extends AbstractNonTextScriptFieldTypeTestCase { public void testFormat() throws IOException { assertThat(simpleMappedFieldType().docValueFormat("#.0", null).format(1), equalTo("1.0")); assertThat(simpleMappedFieldType().docValueFormat("#.0", null).format(1.2), equalTo("1.2")); @@ -69,7 +69,7 @@ public class DoubleScriptMappedFieldTypeTests extends AbstractNonTextScriptMappe List results = new ArrayList<>(); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - DoubleScriptMappedFieldType ft = build("add_param", org.elasticsearch.common.collect.Map.of("param", 1)); + DoubleScriptFieldType ft = build("add_param", org.elasticsearch.common.collect.Map.of("param", 1)); DoubleScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null, null); searcher.search(new MatchAllDocsQuery(), new Collector() { @Override @@ -245,7 +245,7 @@ public class DoubleScriptMappedFieldTypeTests extends AbstractNonTextScriptMappe } @Override - protected DoubleScriptMappedFieldType simpleMappedFieldType() throws IOException { + protected DoubleScriptFieldType simpleMappedFieldType() throws IOException { return build("read_foo", org.elasticsearch.common.collect.Map.of()); } @@ -259,11 +259,11 @@ public class DoubleScriptMappedFieldTypeTests extends AbstractNonTextScriptMappe return "double"; } - private static DoubleScriptMappedFieldType build(String code, Map params) throws IOException { + private static DoubleScriptFieldType build(String code, Map params) throws IOException { return build(new Script(ScriptType.INLINE, "test", code, params)); } - private static DoubleScriptMappedFieldType build(Script script) throws IOException { + private static DoubleScriptFieldType build(Script script) throws IOException { ScriptPlugin scriptPlugin = new ScriptPlugin() { @Override public ScriptEngine getScriptEngine(Settings settings, Collection> contexts) { @@ -329,7 +329,7 @@ public class DoubleScriptMappedFieldTypeTests extends AbstractNonTextScriptMappe ); try (ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptModule.engines, scriptModule.contexts)) { DoubleFieldScript.Factory factory = scriptService.compile(script, DoubleFieldScript.CONTEXT); - return new DoubleScriptMappedFieldType("test", script, factory, emptyMap()); + return new DoubleScriptFieldType("test", script, factory, emptyMap()); } } } diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptMappedFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptFieldTypeTests.java similarity index 96% rename from x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptMappedFieldTypeTests.java rename to x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptFieldTypeTests.java index a7ad1474061..3c3cbc1b38f 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptMappedFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/IpScriptFieldTypeTests.java @@ -54,7 +54,7 @@ import static java.util.Collections.emptyMap; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.sameInstance; -public class IpScriptMappedFieldTypeTests extends AbstractScriptMappedFieldTypeTestCase { +public class IpScriptFieldTypeTests extends AbstractScriptFieldTypeTestCase { public void testFormat() throws IOException { assertThat(simpleMappedFieldType().docValueFormat(null, null), sameInstance(DocValueFormat.IP)); Exception e = expectThrows(IllegalArgumentException.class, () -> simpleMappedFieldType().docValueFormat("ASDFA", null)); @@ -77,7 +77,7 @@ public class IpScriptMappedFieldTypeTests extends AbstractScriptMappedFieldTypeT List results = new ArrayList<>(); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - IpScriptMappedFieldType ft = build("append_param", org.elasticsearch.common.collect.Map.of("param", ".1")); + IpScriptFieldType ft = build("append_param", org.elasticsearch.common.collect.Map.of("param", ".1")); BinaryScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null, null); DocValueFormat format = ft.docValueFormat(null, null); searcher.search(new MatchAllDocsQuery(), new Collector() { @@ -231,7 +231,7 @@ public class IpScriptMappedFieldTypeTests extends AbstractScriptMappedFieldTypeT iw.addDocument(org.elasticsearch.common.collect.List.of(new StoredField("_source", new BytesRef("{\"foo\": [\"200.0.0\"]}")))); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - IpScriptMappedFieldType fieldType = build("append_param", org.elasticsearch.common.collect.Map.of("param", ".1")); + IpScriptFieldType fieldType = build("append_param", org.elasticsearch.common.collect.Map.of("param", ".1")); assertThat(searcher.count(fieldType.termQuery("192.168.0.1", mockContext())), equalTo(1)); assertThat(searcher.count(fieldType.termQuery("192.168.0.7", mockContext())), equalTo(0)); assertThat(searcher.count(fieldType.termQuery("192.168.0.0/16", mockContext())), equalTo(2)); @@ -288,7 +288,7 @@ public class IpScriptMappedFieldTypeTests extends AbstractScriptMappedFieldTypeT } @Override - protected IpScriptMappedFieldType simpleMappedFieldType() throws IOException { + protected IpScriptFieldType simpleMappedFieldType() throws IOException { return build("read_foo", org.elasticsearch.common.collect.Map.of()); } @@ -302,11 +302,11 @@ public class IpScriptMappedFieldTypeTests extends AbstractScriptMappedFieldTypeT return "ip"; } - private static IpScriptMappedFieldType build(String code, Map params) throws IOException { + private static IpScriptFieldType build(String code, Map params) throws IOException { return build(new Script(ScriptType.INLINE, "test", code, params)); } - private static IpScriptMappedFieldType build(Script script) throws IOException { + private static IpScriptFieldType build(Script script) throws IOException { ScriptPlugin scriptPlugin = new ScriptPlugin() { @Override public ScriptEngine getScriptEngine(Settings settings, Collection> contexts) { @@ -372,7 +372,7 @@ public class IpScriptMappedFieldTypeTests extends AbstractScriptMappedFieldTypeT ); try (ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptModule.engines, scriptModule.contexts)) { IpFieldScript.Factory factory = scriptService.compile(script, IpFieldScript.CONTEXT); - return new IpScriptMappedFieldType("test", script, factory, emptyMap()); + return new IpScriptFieldType("test", script, factory, emptyMap()); } } } diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptMappedFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptFieldTypeTests.java similarity index 95% rename from x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptMappedFieldTypeTests.java rename to x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptFieldTypeTests.java index 9099b8dc41f..cad34ef15b0 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptMappedFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/KeywordScriptFieldTypeTests.java @@ -55,7 +55,7 @@ import java.util.Set; import static java.util.Collections.emptyMap; import static org.hamcrest.Matchers.equalTo; -public class KeywordScriptMappedFieldTypeTests extends AbstractScriptMappedFieldTypeTestCase { +public class KeywordScriptFieldTypeTests extends AbstractScriptFieldTypeTestCase { @Override public void testDocValues() throws IOException { try (Directory directory = newDirectory(); RandomIndexWriter iw = new RandomIndexWriter(random(), directory)) { @@ -64,7 +64,7 @@ public class KeywordScriptMappedFieldTypeTests extends AbstractScriptMappedField List results = new ArrayList<>(); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - KeywordScriptMappedFieldType ft = build("append_param", org.elasticsearch.common.collect.Map.of("param", "-suffix")); + KeywordScriptFieldType ft = build("append_param", org.elasticsearch.common.collect.Map.of("param", "-suffix")); StringScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null, null); searcher.search(new MatchAllDocsQuery(), new Collector() { @Override @@ -282,7 +282,7 @@ public class KeywordScriptMappedFieldTypeTests extends AbstractScriptMappedField iw.addDocument(org.elasticsearch.common.collect.List.of(new StoredField("_source", new BytesRef("{\"foo\": [2]}")))); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - KeywordScriptMappedFieldType fieldType = build("append_param", org.elasticsearch.common.collect.Map.of("param", "-suffix")); + KeywordScriptFieldType fieldType = build("append_param", org.elasticsearch.common.collect.Map.of("param", "-suffix")); assertThat(searcher.count(fieldType.termQuery("1-suffix", mockContext())), equalTo(1)); } } @@ -344,7 +344,7 @@ public class KeywordScriptMappedFieldTypeTests extends AbstractScriptMappedField iw.addDocument(org.elasticsearch.common.collect.List.of(new StoredField("_source", new BytesRef("{\"foo\": [2]}")))); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - KeywordScriptMappedFieldType fieldType = build("append_param", org.elasticsearch.common.collect.Map.of("param", "-Suffix")); + KeywordScriptFieldType fieldType = build("append_param", org.elasticsearch.common.collect.Map.of("param", "-Suffix")); QueryShardContext queryShardContext = mockContext(true, fieldType); Query query = new MatchQueryBuilder("test", "1-Suffix").toQuery(queryShardContext); assertThat(searcher.count(query), equalTo(1)); @@ -353,12 +353,12 @@ public class KeywordScriptMappedFieldTypeTests extends AbstractScriptMappedField } @Override - protected KeywordScriptMappedFieldType simpleMappedFieldType() throws IOException { + protected KeywordScriptFieldType simpleMappedFieldType() throws IOException { return build("read_foo", org.elasticsearch.common.collect.Map.of()); } @Override - protected KeywordScriptMappedFieldType loopFieldType() throws IOException { + protected KeywordScriptFieldType loopFieldType() throws IOException { return build("loop", org.elasticsearch.common.collect.Map.of()); } @@ -367,11 +367,11 @@ public class KeywordScriptMappedFieldTypeTests extends AbstractScriptMappedField return "keyword"; } - private static KeywordScriptMappedFieldType build(String code, Map params) throws IOException { + private static KeywordScriptFieldType build(String code, Map params) throws IOException { return build(new Script(ScriptType.INLINE, "test", code, params)); } - private static KeywordScriptMappedFieldType build(Script script) throws IOException { + private static KeywordScriptFieldType build(Script script) throws IOException { ScriptPlugin scriptPlugin = new ScriptPlugin() { @Override public ScriptEngine getScriptEngine(Settings settings, Collection> contexts) { @@ -437,7 +437,7 @@ public class KeywordScriptMappedFieldTypeTests extends AbstractScriptMappedField ); try (ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptModule.engines, scriptModule.contexts)) { StringFieldScript.Factory factory = scriptService.compile(script, StringFieldScript.CONTEXT); - return new KeywordScriptMappedFieldType("test", script, factory, emptyMap()); + return new KeywordScriptFieldType("test", script, factory, emptyMap()); } } } diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptMappedFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptFieldTypeTests.java similarity index 96% rename from x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptMappedFieldTypeTests.java rename to x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptFieldTypeTests.java index fd2a8146193..37d8d64d5f4 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptMappedFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/LongScriptFieldTypeTests.java @@ -54,7 +54,7 @@ import static java.util.Collections.emptyMap; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; -public class LongScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedFieldTypeTestCase { +public class LongScriptFieldTypeTests extends AbstractNonTextScriptFieldTypeTestCase { public void testFormat() throws IOException { assertThat(simpleMappedFieldType().docValueFormat("#.0", null).format(1), equalTo("1.0")); assertThat(simpleMappedFieldType().docValueFormat("#,##0.##", null).format(11), equalTo("11")); @@ -69,7 +69,7 @@ public class LongScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedF List results = new ArrayList<>(); try (DirectoryReader reader = iw.getReader()) { IndexSearcher searcher = newSearcher(reader); - LongScriptMappedFieldType ft = build("add_param", org.elasticsearch.common.collect.Map.of("param", 1)); + LongScriptFieldType ft = build("add_param", org.elasticsearch.common.collect.Map.of("param", 1)); LongScriptFieldData ifd = ft.fielddataBuilder("test", mockContext()::lookup).build(null, null, null); searcher.search(new MatchAllDocsQuery(), new Collector() { @Override @@ -272,12 +272,12 @@ public class LongScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedF } @Override - protected LongScriptMappedFieldType simpleMappedFieldType() throws IOException { + protected LongScriptFieldType simpleMappedFieldType() throws IOException { return build("read_foo", Collections.emptyMap()); } @Override - protected LongScriptMappedFieldType loopFieldType() throws IOException { + protected LongScriptFieldType loopFieldType() throws IOException { return build("loop", org.elasticsearch.common.collect.Map.of()); } @@ -286,11 +286,11 @@ public class LongScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedF return "long"; } - private static LongScriptMappedFieldType build(String code, Map params) throws IOException { + private static LongScriptFieldType build(String code, Map params) throws IOException { return build(new Script(ScriptType.INLINE, "test", code, params)); } - private static LongScriptMappedFieldType build(Script script) throws IOException { + private static LongScriptFieldType build(Script script) throws IOException { ScriptPlugin scriptPlugin = new ScriptPlugin() { @Override public ScriptEngine getScriptEngine(Settings settings, Collection> contexts) { @@ -367,7 +367,7 @@ public class LongScriptMappedFieldTypeTests extends AbstractNonTextScriptMappedF ); try (ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptModule.engines, scriptModule.contexts)) { LongFieldScript.Factory factory = scriptService.compile(script, LongFieldScript.CONTEXT); - return new LongScriptMappedFieldType("test", script, factory, emptyMap()); + return new LongScriptFieldType("test", script, factory, emptyMap()); } } } diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/RuntimeFieldMapperTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/RuntimeFieldMapperTests.java index e732542861f..c422ddf5019 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/RuntimeFieldMapperTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/RuntimeFieldMapperTests.java @@ -329,12 +329,7 @@ public class RuntimeFieldMapperTests extends MapperTestCase { IllegalArgumentException iae = expectThrows( IllegalArgumentException.class, () -> config.buildIndexSort( - field -> new KeywordScriptMappedFieldType( - field, - new Script(""), - mock(StringFieldScript.Factory.class), - Collections.emptyMap() - ), + field -> new KeywordScriptFieldType(field, new Script(""), mock(StringFieldScript.Factory.class), Collections.emptyMap()), (fieldType, searchLookupSupplier) -> indexFieldDataService.getForField(fieldType, "index", searchLookupSupplier) ) );