Shorten runtime field type class names (#63123)
In the codebase there is the non-written convention that classes that extend `MappedFieldType` are generally called `*FieldType`. With this commit we adopt the same convention for runtime field types which allows us to shorten their names by removing the `Mapped` portion which is implicit.
This commit is contained in:
parent
e91f66e22f
commit
a42a516b67
|
@ -32,11 +32,11 @@ import static org.elasticsearch.search.SearchService.ALLOW_EXPENSIVE_QUERIES;
|
|||
/**
|
||||
* Abstract base {@linkplain MappedFieldType} for scripted fields.
|
||||
*/
|
||||
abstract class AbstractScriptMappedFieldType<LeafFactory> extends MappedFieldType {
|
||||
abstract class AbstractScriptFieldType<LeafFactory> extends MappedFieldType {
|
||||
protected final Script script;
|
||||
private final TriFunction<String, Map<String, Object>, SearchLookup, LeafFactory> factory;
|
||||
|
||||
AbstractScriptMappedFieldType(
|
||||
AbstractScriptFieldType(
|
||||
String name,
|
||||
Script script,
|
||||
TriFunction<String, Map<String, Object>, SearchLookup, LeafFactory> factory,
|
|
@ -27,8 +27,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BooleanScriptMappedFieldType extends AbstractScriptMappedFieldType<BooleanFieldScript.LeafFactory> {
|
||||
BooleanScriptMappedFieldType(String name, Script script, BooleanFieldScript.Factory scriptFactory, Map<String, String> meta) {
|
||||
public class BooleanScriptFieldType extends AbstractScriptFieldType<BooleanFieldScript.LeafFactory> {
|
||||
BooleanScriptFieldType(String name, Script script, BooleanFieldScript.Factory scriptFactory, Map<String, String> meta) {
|
||||
super(name, script, scriptFactory::newFactory, meta);
|
||||
}
|
||||
|
|
@ -35,10 +35,10 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class DateScriptMappedFieldType extends AbstractScriptMappedFieldType<DateFieldScript.LeafFactory> {
|
||||
public class DateScriptFieldType extends AbstractScriptFieldType<DateFieldScript.LeafFactory> {
|
||||
private final DateFormatter dateTimeFormatter;
|
||||
|
||||
DateScriptMappedFieldType(
|
||||
DateScriptFieldType(
|
||||
String name,
|
||||
Script script,
|
||||
DateFieldScript.Factory scriptFactory,
|
|
@ -27,8 +27,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class DoubleScriptMappedFieldType extends AbstractScriptMappedFieldType<DoubleFieldScript.LeafFactory> {
|
||||
DoubleScriptMappedFieldType(String name, Script script, DoubleFieldScript.Factory scriptFactory, Map<String, String> meta) {
|
||||
public class DoubleScriptFieldType extends AbstractScriptFieldType<DoubleFieldScript.LeafFactory> {
|
||||
DoubleScriptFieldType(String name, Script script, DoubleFieldScript.Factory scriptFactory, Map<String, String> meta) {
|
||||
super(name, script, scriptFactory::newFactory, meta);
|
||||
}
|
||||
|
|
@ -36,8 +36,8 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class IpScriptMappedFieldType extends AbstractScriptMappedFieldType<IpFieldScript.LeafFactory> {
|
||||
IpScriptMappedFieldType(String name, Script script, IpFieldScript.Factory scriptFactory, Map<String, String> meta) {
|
||||
public final class IpScriptFieldType extends AbstractScriptFieldType<IpFieldScript.LeafFactory> {
|
||||
IpScriptFieldType(String name, Script script, IpFieldScript.Factory scriptFactory, Map<String, String> meta) {
|
||||
super(name, script, scriptFactory::newFactory, meta);
|
||||
}
|
||||
|
|
@ -35,8 +35,8 @@ import java.util.function.Supplier;
|
|||
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
public final class KeywordScriptMappedFieldType extends AbstractScriptMappedFieldType<StringFieldScript.LeafFactory> {
|
||||
KeywordScriptMappedFieldType(String name, Script script, StringFieldScript.Factory scriptFactory, Map<String, String> meta) {
|
||||
public final class KeywordScriptFieldType extends AbstractScriptFieldType<StringFieldScript.LeafFactory> {
|
||||
KeywordScriptFieldType(String name, Script script, StringFieldScript.Factory scriptFactory, Map<String, String> meta) {
|
||||
super(name, script, scriptFactory::newFactory, meta);
|
||||
}
|
||||
|
|
@ -27,8 +27,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class LongScriptMappedFieldType extends AbstractScriptMappedFieldType<LongFieldScript.LeafFactory> {
|
||||
LongScriptMappedFieldType(String name, Script script, LongFieldScript.Factory scriptFactory, Map<String, String> meta) {
|
||||
public class LongScriptFieldType extends AbstractScriptFieldType<LongFieldScript.LeafFactory> {
|
||||
LongScriptFieldType(String name, Script script, LongFieldScript.Factory scriptFactory, Map<String, String> meta) {
|
||||
super(name, script, scriptFactory::newFactory, meta);
|
||||
}
|
||||
|
|
@ -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<String, BiFunction<Builder, BuilderContext, AbstractScriptMappedFieldType<?>>> FIELD_TYPE_RESOLVER =
|
||||
static final Map<String, BiFunction<Builder, BuilderContext, AbstractScriptFieldType<?>>> 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<String> 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<Builder, BuilderContext, AbstractScriptMappedFieldType<?>> fieldTypeResolver = Builder.FIELD_TYPE_RESOLVER.get(
|
||||
BiFunction<Builder, BuilderContext, AbstractScriptFieldType<?>> fieldTypeResolver = Builder.FIELD_TYPE_RESOLVER.get(
|
||||
runtimeType.getValue()
|
||||
);
|
||||
if (fieldTypeResolver == null) {
|
||||
|
|
|
@ -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",
|
|
@ -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;
|
|
@ -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<Long> 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<String, Object> params) throws IOException {
|
||||
private static BooleanScriptFieldType build(String code, Map<String, Object> 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<ScriptContext<?>> 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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<Long> 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<String, Object> params) throws IOException {
|
||||
private static DateScriptFieldType build(String code, Map<String, Object> 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<ScriptContext<?>> 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());
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Double> 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<String, Object> params) throws IOException {
|
||||
private static DoubleScriptFieldType build(String code, Map<String, Object> 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<ScriptContext<?>> 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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<Object> 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<String, Object> params) throws IOException {
|
||||
private static IpScriptFieldType build(String code, Map<String, Object> 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<ScriptContext<?>> 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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<String> 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<String, Object> params) throws IOException {
|
||||
private static KeywordScriptFieldType build(String code, Map<String, Object> 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<ScriptContext<?>> 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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<Long> 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<String, Object> params) throws IOException {
|
||||
private static LongScriptFieldType build(String code, Map<String, Object> 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<ScriptContext<?>> 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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue