diff --git a/x-pack/plugin/runtime-fields/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/runtimefields/rest/CoreTestsWithRuntimeFieldsIT.java b/x-pack/plugin/runtime-fields/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/runtimefields/rest/CoreTestsWithRuntimeFieldsIT.java index 55b275304b4..daf4df02c2d 100644 --- a/x-pack/plugin/runtime-fields/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/runtimefields/rest/CoreTestsWithRuntimeFieldsIT.java +++ b/x-pack/plugin/runtime-fields/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/runtimefields/rest/CoreTestsWithRuntimeFieldsIT.java @@ -200,17 +200,17 @@ public class CoreTestsWithRuntimeFieldsIT extends ESClientYamlSuiteTestCase { private static final Map PAINLESS_TO_EMIT = org.elasticsearch.common.collect.Map.of( BooleanFieldMapper.CONTENT_TYPE, - "emitValue(parse(value));", + "emit(parse(value));", DateFieldMapper.CONTENT_TYPE, - "emitValue(parse(value.toString()));", + "emit(parse(value.toString()));", NumberType.DOUBLE.typeName(), - "emitValue(value instanceof Number ? ((Number) value).doubleValue() : Double.parseDouble(value.toString()));", + "emit(value instanceof Number ? ((Number) value).doubleValue() : Double.parseDouble(value.toString()));", KeywordFieldMapper.CONTENT_TYPE, - "emitValue(value.toString());", + "emit(value.toString());", IpFieldMapper.CONTENT_TYPE, - "emitValue(value.toString());", + "emit(value.toString());", NumberType.LONG.typeName(), - "emitValue(value instanceof Number ? ((Number) value).longValue() : Long.parseLong(value.toString()));" + "emit(value instanceof Number ? ((Number) value).longValue() : Long.parseLong(value.toString()));" ); private static final ExecutableSection ADD_TEMPLATE = new ExecutableSection() { diff --git a/x-pack/plugin/runtime-fields/qa/with-security/src/javaRestTest/java/org/elasticsearch/xpack/security/PermissionsIT.java b/x-pack/plugin/runtime-fields/qa/with-security/src/javaRestTest/java/org/elasticsearch/xpack/security/PermissionsIT.java index 5c93ce96352..6c26fb47309 100644 --- a/x-pack/plugin/runtime-fields/qa/with-security/src/javaRestTest/java/org/elasticsearch/xpack/security/PermissionsIT.java +++ b/x-pack/plugin/runtime-fields/qa/with-security/src/javaRestTest/java/org/elasticsearch/xpack/security/PermissionsIT.java @@ -73,7 +73,7 @@ public class PermissionsIT extends ESRestTestCase { + " \"year\" : {\n" + " \"type\" : \"runtime\", \n" + " \"runtime_type\" : \"keyword\",\n" - + " \"script\" : \"emitValue(doc['date'].value.substring(0,4))\"\n" + + " \"script\" : \"emit(doc['date'].value.substring(0,4))\"\n" + " }\n" + " }\n" + " }\n" @@ -115,7 +115,7 @@ public class PermissionsIT extends ESRestTestCase { + " \"hidden_values_count\" : {\n" + " \"type\" : \"runtime\", \n" + " \"runtime_type\" : \"long\",\n" - + " \"script\" : \"emitValue(doc['hidden'].size())\"\n" + + " \"script\" : \"emit(doc['hidden'].size())\"\n" + " }\n" + " }\n" + " }\n" @@ -164,7 +164,7 @@ public class PermissionsIT extends ESRestTestCase { + " \"year\" : {\n" + " \"type\" : \"runtime\", \n" + " \"runtime_type\" : \"keyword\",\n" - + " \"script\" : \"emitValue(doc['date'].value.substring(0,4))\"\n" + + " \"script\" : \"emit(doc['date'].value.substring(0,4))\"\n" + " }\n" + " }\n" + " }\n" diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/AbstractLongScriptFieldScript.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/AbstractLongScriptFieldScript.java index 93c6ad382d2..39a663ed816 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/AbstractLongScriptFieldScript.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/AbstractLongScriptFieldScript.java @@ -49,7 +49,7 @@ public abstract class AbstractLongScriptFieldScript extends AbstractScriptFieldS return count; } - protected final void emitValue(long v) { + protected final void emit(long v) { checkMaxSize(count); if (values.length < count + 1) { values = ArrayUtil.grow(values, count + 1); diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/BooleanScriptFieldScript.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/BooleanScriptFieldScript.java index d0e3fd4b038..7be6e8ba31a 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/BooleanScriptFieldScript.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/BooleanScriptFieldScript.java @@ -69,7 +69,7 @@ public abstract class BooleanScriptFieldScript extends AbstractScriptFieldScript return falses; } - protected final void emitValue(boolean v) { + protected final void emit(boolean v) { if (v) { trues++; } else { @@ -81,15 +81,15 @@ public abstract class BooleanScriptFieldScript extends AbstractScriptFieldScript return Booleans.parseBoolean(str.toString()); } - public static class EmitValue { + public static class Emit { private final BooleanScriptFieldScript script; - public EmitValue(BooleanScriptFieldScript script) { + public Emit(BooleanScriptFieldScript script) { this.script = script; } public void value(boolean v) { - script.emitValue(v); + script.emit(v); } } } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/DateScriptFieldScript.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/DateScriptFieldScript.java index b169b034f06..a08eb63896c 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/DateScriptFieldScript.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/DateScriptFieldScript.java @@ -58,15 +58,15 @@ public abstract class DateScriptFieldScript extends AbstractLongScriptFieldScrip return millis; } - public static class EmitValue { + public static class Emit { private final DateScriptFieldScript script; - public EmitValue(DateScriptFieldScript script) { + public Emit(DateScriptFieldScript script) { this.script = script; } - public void emitValue(long v) { - script.emitValue(v); + public void emit(long v) { + script.emit(v); } } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/DoubleScriptFieldScript.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/DoubleScriptFieldScript.java index 840f5395aad..0ade80bdb65 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/DoubleScriptFieldScript.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/DoubleScriptFieldScript.java @@ -71,7 +71,7 @@ public abstract class DoubleScriptFieldScript extends AbstractScriptFieldScript return count; } - protected final void emitValue(double v) { + protected final void emit(double v) { checkMaxSize(count); if (values.length < count + 1) { values = ArrayUtil.grow(values, count + 1); @@ -79,15 +79,15 @@ public abstract class DoubleScriptFieldScript extends AbstractScriptFieldScript values[count++] = v; } - public static class EmitValue { + public static class Emit { private final DoubleScriptFieldScript script; - public EmitValue(DoubleScriptFieldScript script) { + public Emit(DoubleScriptFieldScript script) { this.script = script; } - public void emitValue(double v) { - script.emitValue(v); + public void emit(double v) { + script.emit(v); } } } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/IpScriptFieldScript.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/IpScriptFieldScript.java index fe20c572476..49f260f2073 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/IpScriptFieldScript.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/IpScriptFieldScript.java @@ -93,7 +93,7 @@ public abstract class IpScriptFieldScript extends AbstractScriptFieldScript { return count; } - protected final void emitValue(String v) { + protected final void emit(String v) { checkMaxSize(count); if (values.length < count + 1) { values = ArrayUtil.grow(values, count + 1); @@ -101,15 +101,15 @@ public abstract class IpScriptFieldScript extends AbstractScriptFieldScript { values[count++] = new BytesRef(InetAddressPoint.encode(InetAddresses.forString(v))); } - public static class EmitValue { + public static class Emit { private final IpScriptFieldScript script; - public EmitValue(IpScriptFieldScript script) { + public Emit(IpScriptFieldScript script) { this.script = script; } - public void emitValue(String v) { - script.emitValue(v); + public void emit(String v) { + script.emit(v); } } } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/LongScriptFieldScript.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/LongScriptFieldScript.java index cf9852563a3..3835127eccc 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/LongScriptFieldScript.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/LongScriptFieldScript.java @@ -39,15 +39,15 @@ public abstract class LongScriptFieldScript extends AbstractLongScriptFieldScrip super(fieldName, params, searchLookup, ctx); } - public static class EmitValue { + public static class Emit { private final LongScriptFieldScript script; - public EmitValue(LongScriptFieldScript script) { + public Emit(LongScriptFieldScript script) { this.script = script; } - public void emitValue(long v) { - script.emitValue(v); + public void emit(long v) { + script.emit(v); } } } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/StringScriptFieldScript.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/StringScriptFieldScript.java index 9b89e6714bb..e600e6e640f 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/StringScriptFieldScript.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/StringScriptFieldScript.java @@ -65,7 +65,7 @@ public abstract class StringScriptFieldScript extends AbstractScriptFieldScript return results; } - protected final void emitValue(String v) { + protected final void emit(String v) { checkMaxSize(results.size()); chars += v.length(); if (chars > MAX_CHARS) { @@ -82,15 +82,15 @@ public abstract class StringScriptFieldScript extends AbstractScriptFieldScript results.add(v); } - public static class EmitValue { + public static class Emit { private final StringScriptFieldScript script; - public EmitValue(StringScriptFieldScript script) { + public Emit(StringScriptFieldScript script) { this.script = script; } - public void emitValue(String v) { - script.emitValue(v); + public void emit(String v) { + script.emit(v); } } } diff --git a/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/boolean_whitelist.txt b/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/boolean_whitelist.txt index f7d2c90bf8f..d7dd121e4dc 100644 --- a/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/boolean_whitelist.txt +++ b/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/boolean_whitelist.txt @@ -13,8 +13,8 @@ class org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript$Factory @no } static_import { - # The `emitValue` callback to collect values for the field - void emitValue(org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript, boolean) bound_to org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript$EmitValue + # The `emit` callback to collect values for the field + void emit(org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript, boolean) bound_to org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript$Emit # Parse a value from the source to a boolean boolean parse(def) from_class org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript } diff --git a/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/date_whitelist.txt b/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/date_whitelist.txt index 83b636be23d..0f4476ad623 100644 --- a/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/date_whitelist.txt +++ b/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/date_whitelist.txt @@ -13,8 +13,8 @@ class org.elasticsearch.xpack.runtimefields.DateScriptFieldScript$Factory @no_im } static_import { - # The `emitValue` callback to collect values for the field - void emitValue(org.elasticsearch.xpack.runtimefields.DateScriptFieldScript, long) bound_to org.elasticsearch.xpack.runtimefields.DateScriptFieldScript$EmitValue + # The `emit` callback to collect values for the field + void emit(org.elasticsearch.xpack.runtimefields.DateScriptFieldScript, long) bound_to org.elasticsearch.xpack.runtimefields.DateScriptFieldScript$Emit # Parse a value from the source to millis since epoch long parse(org.elasticsearch.xpack.runtimefields.DateScriptFieldScript, def) bound_to org.elasticsearch.xpack.runtimefields.DateScriptFieldScript$Parse # Add an easy method to convert temporalAccessors to millis since epoch. diff --git a/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/double_whitelist.txt b/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/double_whitelist.txt index 41d17f781e8..7b32499f512 100644 --- a/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/double_whitelist.txt +++ b/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/double_whitelist.txt @@ -13,7 +13,7 @@ class org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript$Factory @no_ } static_import { - # The `emitValue` callback to collect values for the field - void emitValue(org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript, double) bound_to org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript$EmitValue + # The `emit` callback to collect values for the field + void emit(org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript, double) bound_to org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript$Emit } diff --git a/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/ip_whitelist.txt b/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/ip_whitelist.txt index 24a334edfda..07b9ec0c793 100644 --- a/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/ip_whitelist.txt +++ b/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/ip_whitelist.txt @@ -13,6 +13,6 @@ class org.elasticsearch.xpack.runtimefields.IpScriptFieldScript$Factory @no_impo } static_import { - # The `emitValue` callback to collect values for the field - void emitValue(org.elasticsearch.xpack.runtimefields.IpScriptFieldScript, String) bound_to org.elasticsearch.xpack.runtimefields.IpScriptFieldScript$EmitValue + # The `emit` callback to collect values for the field + void emit(org.elasticsearch.xpack.runtimefields.IpScriptFieldScript, String) bound_to org.elasticsearch.xpack.runtimefields.IpScriptFieldScript$Emit } diff --git a/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/long_whitelist.txt b/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/long_whitelist.txt index a38a7708eca..4710044bf75 100644 --- a/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/long_whitelist.txt +++ b/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/long_whitelist.txt @@ -13,6 +13,6 @@ class org.elasticsearch.xpack.runtimefields.LongScriptFieldScript$Factory @no_im } static_import { - # The `emitValue` callback to collect values for the field - void emitValue(org.elasticsearch.xpack.runtimefields.LongScriptFieldScript, long) bound_to org.elasticsearch.xpack.runtimefields.LongScriptFieldScript$EmitValue + # The `emit` callback to collect values for the field + void emit(org.elasticsearch.xpack.runtimefields.LongScriptFieldScript, long) bound_to org.elasticsearch.xpack.runtimefields.LongScriptFieldScript$Emit } diff --git a/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/string_whitelist.txt b/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/string_whitelist.txt index 1dfca74fc88..12b7b850776 100644 --- a/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/string_whitelist.txt +++ b/x-pack/plugin/runtime-fields/src/main/resources/org/elasticsearch/xpack/runtimefields/string_whitelist.txt @@ -13,6 +13,6 @@ class org.elasticsearch.xpack.runtimefields.StringScriptFieldScript$Factory @no_ } static_import { - # The `emitValue` callback to collect values for the field - void emitValue(org.elasticsearch.xpack.runtimefields.StringScriptFieldScript, String) bound_to org.elasticsearch.xpack.runtimefields.StringScriptFieldScript$EmitValue + # The `emit` callback to collect values for the field + void emit(org.elasticsearch.xpack.runtimefields.StringScriptFieldScript, String) bound_to org.elasticsearch.xpack.runtimefields.StringScriptFieldScript$Emit } diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/BooleanScriptFieldScriptTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/BooleanScriptFieldScriptTests.java index 4ed0db9e3ed..698d30f5d74 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/BooleanScriptFieldScriptTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/BooleanScriptFieldScriptTests.java @@ -28,7 +28,7 @@ public class BooleanScriptFieldScriptTests extends ScriptFieldScriptTestCase) getSource().get("foo")) { - emitValue(parse(foo)); + emit(parse(foo)); } } }; @@ -481,7 +481,7 @@ public class ScriptBooleanMappedFieldTypeTests extends AbstractNonTextScriptMapp @Override public void execute() { for (Object foo : (List) getSource().get("foo")) { - emitValue((Boolean) foo ^ ((Boolean) getParams().get("param"))); + emit((Boolean) foo ^ ((Boolean) getParams().get("param"))); } } }; diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptDateMappedFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptDateMappedFieldTypeTests.java index 757448e6728..04785df39dc 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptDateMappedFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptDateMappedFieldTypeTests.java @@ -515,7 +515,7 @@ public class ScriptDateMappedFieldTypeTests extends AbstractNonTextScriptMappedF public void execute() { for (Object timestamp : (List) getSource().get("timestamp")) { DateScriptFieldScript.Parse parse = new DateScriptFieldScript.Parse(this); - emitValue(parse.parse(timestamp)); + emit(parse.parse(timestamp)); } } }; @@ -533,7 +533,7 @@ public class ScriptDateMappedFieldTypeTests extends AbstractNonTextScriptMappedF long epoch = (Long) timestamp; ZonedDateTime dt = ZonedDateTime.ofInstant(Instant.ofEpochMilli(epoch), ZoneId.of("UTC")); dt = dt.plus(((Number) params.get("days")).longValue(), ChronoUnit.DAYS); - emitValue(toEpochMilli(dt)); + emit(toEpochMilli(dt)); } } }; diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptDoubleMappedFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptDoubleMappedFieldTypeTests.java index 6626562fdbd..5f1d3e08903 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptDoubleMappedFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptDoubleMappedFieldTypeTests.java @@ -299,7 +299,7 @@ public class ScriptDoubleMappedFieldTypeTests extends AbstractNonTextScriptMappe @Override public void execute() { for (Object foo : (List) getSource().get("foo")) { - emitValue(((Number) foo).doubleValue()); + emit(((Number) foo).doubleValue()); } } }; @@ -308,7 +308,7 @@ public class ScriptDoubleMappedFieldTypeTests extends AbstractNonTextScriptMappe @Override public void execute() { for (Object foo : (List) getSource().get("foo")) { - emitValue(((Number) foo).doubleValue() + ((Number) getParams().get("param")).doubleValue()); + emit(((Number) foo).doubleValue() + ((Number) getParams().get("param")).doubleValue()); } } }; diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptIpMappedFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptIpMappedFieldTypeTests.java index 2ca12fb6d00..bd668283fd2 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptIpMappedFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptIpMappedFieldTypeTests.java @@ -342,7 +342,7 @@ public class ScriptIpMappedFieldTypeTests extends AbstractScriptMappedFieldTypeT @Override public void execute() { for (Object foo : (List) getSource().get("foo")) { - emitValue(foo.toString()); + emit(foo.toString()); } } }; @@ -351,7 +351,7 @@ public class ScriptIpMappedFieldTypeTests extends AbstractScriptMappedFieldTypeT @Override public void execute() { for (Object foo : (List) getSource().get("foo")) { - emitValue(foo.toString() + getParams().get("param")); + emit(foo.toString() + getParams().get("param")); } } }; diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptKeywordMappedFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptKeywordMappedFieldTypeTests.java index 71cd4b1d0bc..741510388dc 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptKeywordMappedFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptKeywordMappedFieldTypeTests.java @@ -383,7 +383,7 @@ public class ScriptKeywordMappedFieldTypeTests extends AbstractScriptMappedField @Override public void execute() { for (Object foo : (List) getSource().get("foo")) { - emitValue(foo.toString()); + emit(foo.toString()); } } }; @@ -392,7 +392,7 @@ public class ScriptKeywordMappedFieldTypeTests extends AbstractScriptMappedField @Override public void execute() { for (Object foo : (List) getSource().get("foo")) { - emitValue(foo.toString() + getParams().get("param").toString()); + emit(foo.toString() + getParams().get("param").toString()); } } }; diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptLongMappedFieldTypeTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptLongMappedFieldTypeTests.java index 33c9c1a98ec..2127b93c061 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptLongMappedFieldTypeTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/mapper/ScriptLongMappedFieldTypeTests.java @@ -328,7 +328,7 @@ public class ScriptLongMappedFieldTypeTests extends AbstractNonTextScriptMappedF @Override public void execute() { for (Object foo : (List) getSource().get("foo")) { - emitValue(((Number) foo).longValue()); + emit(((Number) foo).longValue()); } } }; @@ -337,7 +337,7 @@ public class ScriptLongMappedFieldTypeTests extends AbstractNonTextScriptMappedF @Override public void execute() { for (Object foo : (List) getSource().get("foo")) { - emitValue(((Number) foo).longValue() + ((Number) getParams().get("param")).longValue()); + emit(((Number) foo).longValue() + ((Number) getParams().get("param")).longValue()); } } }; @@ -348,7 +348,7 @@ public class ScriptLongMappedFieldTypeTests extends AbstractNonTextScriptMappedF @Override public void execute() { for (Object timestamp : (List) getSource().get("timestamp")) { - emitValue(now - ((Number) timestamp).longValue()); + emit(now - ((Number) timestamp).longValue()); } } }; diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/query/LongScriptFieldDistanceFeatureQueryTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/query/LongScriptFieldDistanceFeatureQueryTests.java index bc1c51adee6..bb9d0a804ad 100644 --- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/query/LongScriptFieldDistanceFeatureQueryTests.java +++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/query/LongScriptFieldDistanceFeatureQueryTests.java @@ -95,7 +95,7 @@ public class LongScriptFieldDistanceFeatureQueryTests extends AbstractScriptFiel @Override public void execute() { for (Object timestamp : (List) getSource().get("timestamp")) { - emitValue(((Number) timestamp).longValue()); + emit(((Number) timestamp).longValue()); } } }; diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml index 786ccd4a8c4..d346e3980a3 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/10_keyword.yml @@ -22,7 +22,7 @@ setup: type: runtime runtime_type: keyword script: | - emitValue(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT)); + emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT)); # Test fetching from _source day_of_week_from_source: type: runtime @@ -30,7 +30,7 @@ setup: script: | Instant instant = Instant.ofEpochMilli(params._source.timestamp); ZonedDateTime dt = ZonedDateTime.ofInstant(instant, ZoneId.of("UTC")); - emitValue(dt.dayOfWeek.getDisplayName(TextStyle.FULL, Locale.ROOT)); + emit(dt.dayOfWeek.getDisplayName(TextStyle.FULL, Locale.ROOT)); # Test fetching many values day_of_week_letters: type: runtime @@ -38,7 +38,7 @@ setup: script: | for (String dow: doc['day_of_week']) { for (int i = 0; i < dow.length(); i++) { - emitValue(dow.charAt(i).toString()); + emit(dow.charAt(i).toString()); } } prefixed_node: @@ -47,7 +47,7 @@ setup: script: source: | for (String node : params._fields.node.values) { - emitValue(params.prefix + node); + emit(params.prefix + node); } params: prefix: node_ @@ -79,7 +79,7 @@ setup: - match: {sensor.mappings.properties.day_of_week.runtime_type: keyword } - match: sensor.mappings.properties.day_of_week.script.source: | - emitValue(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT)); + emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT)); - match: {sensor.mappings.properties.day_of_week.script.lang: painless } --- @@ -95,7 +95,7 @@ setup: runtime_type: keyword script: source: | - emitValue(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT)); + emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT)); lang: painless meta: {} @@ -204,11 +204,11 @@ setup: first_script: type: runtime runtime_type: keyword - script: emitValue(doc['users.first'].value) + script: emit(doc['users.first'].value) last_script: type: runtime runtime_type: keyword - script: emitValue(doc['users.last'].value) + script: emit(doc['users.last'].value) - do: bulk: index: test diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml index d75fc47d6f1..9160075a068 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/20_long.yml @@ -23,7 +23,7 @@ setup: script: source: | for (double v : doc['voltage']) { - emitValue((long)(v * params.multiplier)); + emit((long)(v * params.multiplier)); } params: multiplier: 10 @@ -33,7 +33,7 @@ setup: runtime_type: long script: source: | - emitValue((long)(params._source.voltage * params.multiplier)); + emit((long)(params._source.voltage * params.multiplier)); params: multiplier: 10 # Test fetching many values @@ -45,7 +45,7 @@ setup: for (long temperature : doc['temperature']) { long t = temperature; while (t != 0) { - emitValue(t % 10); + emit(t % 10); t /= 10; } } @@ -56,7 +56,7 @@ setup: script: source: | for (def dt : doc['timestamp']) { - emitValue(System.currentTimeMillis() - dt.toInstant().toEpochMilli()); + emit(System.currentTimeMillis() - dt.toInstant().toEpochMilli()); } - do: @@ -87,7 +87,7 @@ setup: - match: sensor.mappings.properties.voltage_times_ten.script.source: | for (double v : doc['voltage']) { - emitValue((long)(v * params.multiplier)); + emit((long)(v * params.multiplier)); } - match: {sensor.mappings.properties.voltage_times_ten.script.params: {multiplier: 10} } - match: {sensor.mappings.properties.voltage_times_ten.script.lang: painless } @@ -167,11 +167,11 @@ setup: first_script: type: runtime runtime_type: long - script: emitValue(doc['users.first'].value.length()) + script: emit(doc['users.first'].value.length()) last_script: type: runtime runtime_type: long - script: emitValue(doc['users.last'].value.length()) + script: emit(doc['users.last'].value.length()) - do: bulk: index: test diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml index ecf97a88e72..a30ebf53f46 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/30_double.yml @@ -23,7 +23,7 @@ setup: script: source: | for (double v : doc['voltage']) { - emitValue(v / params.max); + emit(v / params.max); } params: max: 5.8 @@ -33,7 +33,7 @@ setup: runtime_type: double script: source: | - emitValue(params._source.voltage / params.max); + emit(params._source.voltage / params.max); params: max: 5.8 # Test fetching many values @@ -45,7 +45,7 @@ setup: for (double voltage : doc['voltage']) { double v = voltage; while (v > 1.2) { - emitValue(v); + emit(v); v = Math.sqrt(v); } } @@ -78,7 +78,7 @@ setup: - match: sensor.mappings.properties.voltage_percent.script.source: | for (double v : doc['voltage']) { - emitValue(v / params.max); + emit(v / params.max); } - match: {sensor.mappings.properties.voltage_percent.script.params: {max: 5.8} } - match: {sensor.mappings.properties.voltage_percent.script.lang: painless } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml index 12052bcc5b9..7497806aefe 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/40_date.yml @@ -23,7 +23,7 @@ setup: script: source: | for (def dt : doc['timestamp']) { - emitValue(toEpochMilli(dt.plus(params.days, ChronoUnit.DAYS))); + emit(toEpochMilli(dt.plus(params.days, ChronoUnit.DAYS))); } params: days: 1 @@ -35,7 +35,7 @@ setup: source: | Instant instant = Instant.ofEpochMilli(parse(params._source.timestamp)); ZonedDateTime dt = ZonedDateTime.ofInstant(instant, ZoneId.of("UTC")); - emitValue(toEpochMilli(dt.plus(1, ChronoUnit.DAYS))); + emit(toEpochMilli(dt.plus(1, ChronoUnit.DAYS))); # Test returning millis the_past: type: runtime @@ -43,7 +43,7 @@ setup: script: source: | for (def dt : doc['timestamp']) { - emitValue(dt.toInstant().toEpochMilli() - 1000); + emit(dt.toInstant().toEpochMilli() - 1000); } # Test fetching many values all_week: @@ -53,7 +53,7 @@ setup: source: | for (def dt : doc['timestamp']) { for (int i = 0; i < 7; i++) { - emitValue(toEpochMilli(dt.plus(i, ChronoUnit.DAYS))); + emit(toEpochMilli(dt.plus(i, ChronoUnit.DAYS))); } } # Test format parameter @@ -63,7 +63,7 @@ setup: format: yyyy-MM-dd script: | for (def dt : doc['timestamp']) { - emitValue(toEpochMilli(dt.plus(1, ChronoUnit.DAYS))); + emit(toEpochMilli(dt.plus(1, ChronoUnit.DAYS))); } - do: @@ -94,7 +94,7 @@ setup: - match: sensor.mappings.properties.tomorrow.script.source: | for (def dt : doc['timestamp']) { - emitValue(toEpochMilli(dt.plus(params.days, ChronoUnit.DAYS))); + emit(toEpochMilli(dt.plus(params.days, ChronoUnit.DAYS))); } - match: {sensor.mappings.properties.tomorrow.script.params: {days: 1} } - match: {sensor.mappings.properties.tomorrow.script.lang: painless } @@ -104,7 +104,7 @@ setup: - match: sensor.mappings.properties.formatted_tomorrow.script.source: | for (def dt : doc['timestamp']) { - emitValue(toEpochMilli(dt.plus(1, ChronoUnit.DAYS))); + emit(toEpochMilli(dt.plus(1, ChronoUnit.DAYS))); } - match: {sensor.mappings.properties.formatted_tomorrow.script.lang: painless } - match: {sensor.mappings.properties.formatted_tomorrow.format: yyyy-MM-dd } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml index c9a7fe33e75..8ee5dc8c0c4 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/50_ip.yml @@ -20,7 +20,7 @@ setup: source: | String m = doc["message"].value; int end = m.indexOf(" "); - emitValue(m.substring(0, end)); + emit(m.substring(0, end)); # Test fetching from _source ip_from_source: type: runtime @@ -29,7 +29,7 @@ setup: source: | String m = params._source.message; int end = m.indexOf(" "); - emitValue(m.substring(0, end)); + emit(m.substring(0, end)); # Test emitting many values ip_many: type: runtime @@ -41,7 +41,7 @@ setup: end = m.lastIndexOf(".", end); String stem = m.substring(0, end + 1); for (int i = 0; i < 5; i++) { - emitValue(stem + i); + emit(stem + i); } - do: bulk: @@ -73,7 +73,7 @@ setup: http_logs.mappings.properties.ip.script.source: | String m = doc["message"].value; int end = m.indexOf(" "); - emitValue(m.substring(0, end)); + emit(m.substring(0, end)); - match: {http_logs.mappings.properties.ip.script.lang: painless } --- diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml index 10e167bca20..f6e8f420694 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/60_boolean.yml @@ -23,7 +23,7 @@ setup: script: source: | for (def v : doc['voltage']) { - emitValue(v >= params.min_v); + emit(v >= params.min_v); } params: min_v: 5.0 @@ -33,7 +33,7 @@ setup: runtime_type: boolean script: source: | - emitValue(params._source.voltage >= 5.0); + emit(params._source.voltage >= 5.0); # Test many booleans big_vals: type: runtime @@ -41,10 +41,10 @@ setup: script: source: | for (def v : doc['temperature']) { - emitValue(v >= 200); + emit(v >= 200); } for (def v : doc['voltage']) { - emitValue(v >= 5.0); + emit(v >= 5.0); } - do: @@ -75,7 +75,7 @@ setup: - match: sensor.mappings.properties.over_v.script.source: | for (def v : doc['voltage']) { - emitValue(v >= params.min_v); + emit(v >= params.min_v); } - match: {sensor.mappings.properties.over_v.script.params: {min_v: 5.0} } - match: {sensor.mappings.properties.over_v.script.lang: painless } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/80_multiple_indices.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/80_multiple_indices.yml index e309ca01c20..8c349f4719e 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/80_multiple_indices.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/80_multiple_indices.yml @@ -17,14 +17,14 @@ setup: type: runtime runtime_type: keyword script: | - emitValue(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT)); + emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT)); tomorrow: type: runtime runtime_type: date script: source: | for (def dt : doc['timestamp']) { - emitValue(toEpochMilli(dt.plus(params.days, ChronoUnit.DAYS))); + emit(toEpochMilli(dt.plus(params.days, ChronoUnit.DAYS))); } params: days: 1 @@ -36,7 +36,7 @@ setup: script: source: | for (double v : doc['voltage']) { - emitValue((long)(v * params.multiplier)); + emit((long)(v * params.multiplier)); } params: multiplier: 10 @@ -46,7 +46,7 @@ setup: script: source: | for (double v : doc['voltage']) { - emitValue(v / params.max); + emit(v / params.max); } params: max: 5.8 @@ -57,14 +57,14 @@ setup: source: | String m = doc["message"].value; int end = m.indexOf(" "); - emitValue(m.substring(0, end)); + emit(m.substring(0, end)); over_v: type: runtime runtime_type: boolean script: source: | for (def v : doc['voltage']) { - emitValue(v >= params.min_v); + emit(v >= params.min_v); } params: min_v: 5.0 diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/90_loops.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/90_loops.yml index 335b345f0cb..7d8ee4c680d 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/90_loops.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/runtime_fields/90_loops.yml @@ -20,51 +20,51 @@ setup: tight_loop: type: runtime runtime_type: keyword - script: emitValue(doc['tight_loop'].value) + script: emit(doc['tight_loop'].value) loose_loop: type: runtime runtime_type: keyword - script: emitValue(doc['lla'].value) + script: emit(doc['lla'].value) lla: type: runtime runtime_type: keyword - script: emitValue(doc['llb'].value) + script: emit(doc['llb'].value) llb: type: runtime runtime_type: keyword - script: emitValue(doc['llc'].value) + script: emit(doc['llc'].value) llc: type: runtime runtime_type: keyword - script: emitValue(doc['loose_loop'].value) + script: emit(doc['loose_loop'].value) refs: type: runtime runtime_type: keyword - script: emitValue(doc['over_max_depth_2'].value + doc['over_max_depth_3'].value + doc['over_max_depth_4'].value + doc['over_max_depth_5'].value + doc['node'].value) + script: emit(doc['over_max_depth_2'].value + doc['over_max_depth_3'].value + doc['over_max_depth_4'].value + doc['over_max_depth_5'].value + doc['node'].value) over_max_depth: type: runtime runtime_type: keyword - script: emitValue(doc['over_max_depth_1'].value) + script: emit(doc['over_max_depth_1'].value) over_max_depth_1: type: runtime runtime_type: keyword - script: emitValue(doc['over_max_depth_2'].value) + script: emit(doc['over_max_depth_2'].value) over_max_depth_2: type: runtime runtime_type: keyword - script: emitValue(doc['over_max_depth_3'].value) + script: emit(doc['over_max_depth_3'].value) over_max_depth_3: type: runtime runtime_type: keyword - script: emitValue(doc['over_max_depth_4'].value) + script: emit(doc['over_max_depth_4'].value) over_max_depth_4: type: runtime runtime_type: keyword - script: emitValue(doc['over_max_depth_5'].value) + script: emit(doc['over_max_depth_5'].value) over_max_depth_5: type: runtime runtime_type: keyword - script: emitValue('test') + script: emit('test') - do: bulk: