Runtime fields: rename script classes (#62448)

With this commit we rename the script classes used for each mapped field type used for runtime fields. The new naming is a shorter version of the previous one: from e.g. BooleanScriptFieldScrip to BooleanScript . We also move such classes to the existing mapper package.
This commit is contained in:
Luca Cavanna 2020-09-16 18:00:06 +02:00 committed by GitHub
parent f347f0207f
commit 1e352fdb7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
87 changed files with 360 additions and 440 deletions

View File

@ -11,7 +11,13 @@ import org.elasticsearch.plugins.MapperPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.ScriptPlugin;
import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.xpack.runtimefields.mapper.BooleanFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DateFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.LongFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.RuntimeFieldMapper;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.Collections;
import java.util.List;
@ -27,12 +33,12 @@ public final class RuntimeFields extends Plugin implements MapperPlugin, ScriptP
@Override
public List<ScriptContext<?>> getContexts() {
return org.elasticsearch.common.collect.List.of(
BooleanScriptFieldScript.CONTEXT,
DateScriptFieldScript.CONTEXT,
DoubleScriptFieldScript.CONTEXT,
IpScriptFieldScript.CONTEXT,
LongScriptFieldScript.CONTEXT,
StringScriptFieldScript.CONTEXT
BooleanFieldScript.CONTEXT,
DateFieldScript.CONTEXT,
DoubleFieldScript.CONTEXT,
IpFieldScript.CONTEXT,
LongFieldScript.CONTEXT,
StringFieldScript.CONTEXT
);
}
}

View File

@ -7,15 +7,15 @@
package org.elasticsearch.xpack.runtimefields.fielddata;
import org.elasticsearch.index.fielddata.AbstractSortedNumericDocValues;
import org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.BooleanFieldScript;
import java.io.IOException;
public final class ScriptBooleanDocValues extends AbstractSortedNumericDocValues {
private final BooleanScriptFieldScript script;
private final BooleanFieldScript script;
private int cursor;
ScriptBooleanDocValues(BooleanScriptFieldScript script) {
ScriptBooleanDocValues(BooleanFieldScript script) {
this.script = script;
}

View File

@ -17,7 +17,7 @@ import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
import org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.BooleanFieldScript;
import java.io.IOException;
@ -25,9 +25,9 @@ public final class ScriptBooleanFieldData extends IndexNumericFieldData {
public static class Builder implements IndexFieldData.Builder {
private final String name;
private final BooleanScriptFieldScript.LeafFactory leafFactory;
private final BooleanFieldScript.LeafFactory leafFactory;
public Builder(String name, BooleanScriptFieldScript.LeafFactory leafFactory) {
public Builder(String name, BooleanFieldScript.LeafFactory leafFactory) {
this.name = name;
this.leafFactory = leafFactory;
}
@ -39,9 +39,9 @@ public final class ScriptBooleanFieldData extends IndexNumericFieldData {
}
private final String fieldName;
private final BooleanScriptFieldScript.LeafFactory leafFactory;
private final BooleanFieldScript.LeafFactory leafFactory;
private ScriptBooleanFieldData(String fieldName, BooleanScriptFieldScript.LeafFactory leafFactory) {
private ScriptBooleanFieldData(String fieldName, BooleanFieldScript.LeafFactory leafFactory) {
this.fieldName = fieldName;
this.leafFactory = leafFactory;
}

View File

@ -17,7 +17,7 @@ import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
import org.elasticsearch.xpack.runtimefields.DateScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DateFieldScript;
import java.io.IOException;
@ -25,9 +25,9 @@ public final class ScriptDateFieldData extends IndexNumericFieldData {
public static class Builder implements IndexFieldData.Builder {
private final String name;
private final DateScriptFieldScript.LeafFactory leafFactory;
private final DateFieldScript.LeafFactory leafFactory;
public Builder(String name, DateScriptFieldScript.LeafFactory leafFactory) {
public Builder(String name, DateFieldScript.LeafFactory leafFactory) {
this.name = name;
this.leafFactory = leafFactory;
}
@ -39,9 +39,9 @@ public final class ScriptDateFieldData extends IndexNumericFieldData {
}
private final String fieldName;
private final DateScriptFieldScript.LeafFactory leafFactory;
private final DateFieldScript.LeafFactory leafFactory;
private ScriptDateFieldData(String fieldName, DateScriptFieldScript.LeafFactory leafFactory) {
private ScriptDateFieldData(String fieldName, DateFieldScript.LeafFactory leafFactory) {
this.fieldName = fieldName;
this.leafFactory = leafFactory;
}

View File

@ -7,16 +7,16 @@
package org.elasticsearch.xpack.runtimefields.fielddata;
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript;
import java.io.IOException;
import java.util.Arrays;
public final class ScriptDoubleDocValues extends SortedNumericDoubleValues {
private final DoubleScriptFieldScript script;
private final DoubleFieldScript script;
private int cursor;
ScriptDoubleDocValues(DoubleScriptFieldScript script) {
ScriptDoubleDocValues(DoubleFieldScript script) {
this.script = script;
}

View File

@ -17,7 +17,7 @@ import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript;
import java.io.IOException;
@ -25,9 +25,9 @@ public final class ScriptDoubleFieldData extends IndexNumericFieldData {
public static class Builder implements IndexFieldData.Builder {
private final String name;
private final DoubleScriptFieldScript.LeafFactory leafFactory;
private final DoubleFieldScript.LeafFactory leafFactory;
public Builder(String name, DoubleScriptFieldScript.LeafFactory leafFactory) {
public Builder(String name, DoubleFieldScript.LeafFactory leafFactory) {
this.name = name;
this.leafFactory = leafFactory;
}
@ -39,9 +39,9 @@ public final class ScriptDoubleFieldData extends IndexNumericFieldData {
}
private final String fieldName;
DoubleScriptFieldScript.LeafFactory leafFactory;
DoubleFieldScript.LeafFactory leafFactory;
private ScriptDoubleFieldData(String fieldName, DoubleScriptFieldScript.LeafFactory leafFactory) {
private ScriptDoubleFieldData(String fieldName, DoubleFieldScript.LeafFactory leafFactory) {
this.fieldName = fieldName;
this.leafFactory = leafFactory;
}

View File

@ -8,16 +8,16 @@ package org.elasticsearch.xpack.runtimefields.fielddata;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.index.fielddata.SortedBinaryDocValues;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript;
import java.io.IOException;
import java.util.Arrays;
public final class ScriptIpDocValues extends SortedBinaryDocValues {
private final IpScriptFieldScript script;
private final IpFieldScript script;
private int cursor;
ScriptIpDocValues(IpScriptFieldScript script) {
ScriptIpDocValues(IpFieldScript script) {
this.script = script;
}

View File

@ -21,16 +21,16 @@ import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript;
import java.net.InetAddress;
public class ScriptIpFieldData extends ScriptBinaryFieldData {
public static class Builder implements IndexFieldData.Builder {
private final String name;
private final IpScriptFieldScript.LeafFactory leafFactory;
private final IpFieldScript.LeafFactory leafFactory;
public Builder(String name, IpScriptFieldScript.LeafFactory leafFactory) {
public Builder(String name, IpFieldScript.LeafFactory leafFactory) {
this.name = name;
this.leafFactory = leafFactory;
}
@ -41,16 +41,16 @@ public class ScriptIpFieldData extends ScriptBinaryFieldData {
}
}
private final IpScriptFieldScript.LeafFactory leafFactory;
private final IpFieldScript.LeafFactory leafFactory;
private ScriptIpFieldData(String fieldName, IpScriptFieldScript.LeafFactory leafFactory) {
private ScriptIpFieldData(String fieldName, IpFieldScript.LeafFactory leafFactory) {
super(fieldName);
this.leafFactory = leafFactory;
}
@Override
public ScriptBinaryLeafFieldData loadDirect(LeafReaderContext context) throws Exception {
IpScriptFieldScript script = leafFactory.newInstance(context);
IpFieldScript script = leafFactory.newInstance(context);
return new ScriptBinaryLeafFieldData() {
@Override
public ScriptDocValues<String> getScriptValues() {

View File

@ -7,16 +7,16 @@
package org.elasticsearch.xpack.runtimefields.fielddata;
import org.elasticsearch.index.fielddata.AbstractSortedNumericDocValues;
import org.elasticsearch.xpack.runtimefields.AbstractLongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.AbstractLongFieldScript;
import java.io.IOException;
import java.util.Arrays;
public final class ScriptLongDocValues extends AbstractSortedNumericDocValues {
private final AbstractLongScriptFieldScript script;
private final AbstractLongFieldScript script;
private int cursor;
ScriptLongDocValues(AbstractLongScriptFieldScript script) {
ScriptLongDocValues(AbstractLongFieldScript script) {
this.script = script;
}

View File

@ -17,7 +17,7 @@ import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
import org.elasticsearch.xpack.runtimefields.LongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.LongFieldScript;
import java.io.IOException;
@ -25,9 +25,9 @@ public final class ScriptLongFieldData extends IndexNumericFieldData {
public static class Builder implements IndexFieldData.Builder {
private final String name;
private final LongScriptFieldScript.LeafFactory leafFactory;
private final LongFieldScript.LeafFactory leafFactory;
public Builder(String name, LongScriptFieldScript.LeafFactory leafFactory) {
public Builder(String name, LongFieldScript.LeafFactory leafFactory) {
this.name = name;
this.leafFactory = leafFactory;
}
@ -39,9 +39,9 @@ public final class ScriptLongFieldData extends IndexNumericFieldData {
}
private final String fieldName;
private final LongScriptFieldScript.LeafFactory leafFactory;
private final LongFieldScript.LeafFactory leafFactory;
private ScriptLongFieldData(String fieldName, LongScriptFieldScript.LeafFactory leafFactory) {
private ScriptLongFieldData(String fieldName, LongFieldScript.LeafFactory leafFactory) {
this.fieldName = fieldName;
this.leafFactory = leafFactory;
}

View File

@ -7,14 +7,14 @@
package org.elasticsearch.xpack.runtimefields.fielddata;
import org.elasticsearch.index.fielddata.SortingBinaryDocValues;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.List;
public final class ScriptStringDocValues extends SortingBinaryDocValues {
private final StringScriptFieldScript script;
private final StringFieldScript script;
ScriptStringDocValues(StringScriptFieldScript script) {
ScriptStringDocValues(StringFieldScript script) {
this.script = script;
}

View File

@ -15,14 +15,14 @@ import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
public class ScriptStringFieldData extends ScriptBinaryFieldData {
public static class Builder implements IndexFieldData.Builder {
private final String name;
private final StringScriptFieldScript.LeafFactory leafFactory;
private final StringFieldScript.LeafFactory leafFactory;
public Builder(String name, StringScriptFieldScript.LeafFactory leafFactory) {
public Builder(String name, StringFieldScript.LeafFactory leafFactory) {
this.name = name;
this.leafFactory = leafFactory;
}
@ -33,16 +33,16 @@ public class ScriptStringFieldData extends ScriptBinaryFieldData {
}
}
private final StringScriptFieldScript.LeafFactory leafFactory;
private final StringFieldScript.LeafFactory leafFactory;
private ScriptStringFieldData(String fieldName, StringScriptFieldScript.LeafFactory leafFactory) {
private ScriptStringFieldData(String fieldName, StringFieldScript.LeafFactory leafFactory) {
super(fieldName);
this.leafFactory = leafFactory;
}
@Override
public ScriptBinaryLeafFieldData loadDirect(LeafReaderContext context) throws Exception {
StringScriptFieldScript script = leafFactory.newInstance(context);
StringFieldScript script = leafFactory.newInstance(context);
return new ScriptBinaryLeafFieldData() {
@Override
public ScriptDocValues<?> getScriptValues() {

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.index.fielddata.ScriptDocValues;
@ -27,7 +27,7 @@ import static org.elasticsearch.common.unit.TimeValue.timeValueMillis;
* Abstract base for scripts to execute to build scripted fields. Inspired by
* {@link AggregationScript} but hopefully with less historical baggage.
*/
public abstract class AbstractScriptFieldScript {
public abstract class AbstractFieldScript {
/**
* The maximum number of values a script should be allowed to emit.
*/
@ -64,7 +64,7 @@ public abstract class AbstractScriptFieldScript {
private final Map<String, Object> params;
private final LeafSearchLookup leafSearchLookup;
public AbstractScriptFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
public AbstractFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
this.fieldName = fieldName;
this.leafSearchLookup = searchLookup.getLeafSearchLookup(ctx);
params = new HashMap<>(params);

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.util.ArrayUtil;
@ -15,11 +15,11 @@ import java.util.Map;
/**
* Common base class for script field scripts that return long values.
*/
public abstract class AbstractLongScriptFieldScript extends AbstractScriptFieldScript {
public abstract class AbstractLongFieldScript extends AbstractFieldScript {
private long[] values = new long[1];
private int count;
public AbstractLongScriptFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
public AbstractLongFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
super(fieldName, params, searchLookup, ctx);
}

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.common.Booleans;
@ -18,7 +18,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
public abstract class BooleanScriptFieldScript extends AbstractScriptFieldScript {
public abstract class BooleanFieldScript extends AbstractFieldScript {
public static final ScriptContext<Factory> CONTEXT = newContext("boolean_script_field", Factory.class);
static List<Whitelist> whitelist() {
@ -35,13 +35,13 @@ public abstract class BooleanScriptFieldScript extends AbstractScriptFieldScript
}
public interface LeafFactory {
BooleanScriptFieldScript newInstance(LeafReaderContext ctx);
BooleanFieldScript newInstance(LeafReaderContext ctx);
}
private int trues;
private int falses;
public BooleanScriptFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
public BooleanFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
super(fieldName, params, searchLookup, ctx);
}
@ -82,9 +82,9 @@ public abstract class BooleanScriptFieldScript extends AbstractScriptFieldScript
}
public static class Emit {
private final BooleanScriptFieldScript script;
private final BooleanFieldScript script;
public Emit(BooleanScriptFieldScript script) {
public Emit(BooleanFieldScript script) {
this.script = script;
}

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.common.time.DateFormatter;
@ -20,7 +20,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
public abstract class DateScriptFieldScript extends AbstractLongScriptFieldScript {
public abstract class DateFieldScript extends AbstractLongFieldScript {
public static final ScriptContext<Factory> CONTEXT = newContext("date", Factory.class);
static List<Whitelist> whitelist() {
@ -35,12 +35,12 @@ public abstract class DateScriptFieldScript extends AbstractLongScriptFieldScrip
}
public interface LeafFactory {
DateScriptFieldScript newInstance(LeafReaderContext ctx);
DateFieldScript newInstance(LeafReaderContext ctx);
}
private final DateFormatter formatter;
public DateScriptFieldScript(
public DateFieldScript(
String fieldName,
Map<String, Object> params,
SearchLookup searchLookup,
@ -59,9 +59,9 @@ public abstract class DateScriptFieldScript extends AbstractLongScriptFieldScrip
}
public static class Emit {
private final DateScriptFieldScript script;
private final DateFieldScript script;
public Emit(DateScriptFieldScript script) {
public Emit(DateFieldScript script) {
this.script = script;
}
@ -71,9 +71,9 @@ public abstract class DateScriptFieldScript extends AbstractLongScriptFieldScrip
}
public static class Parse {
private final DateScriptFieldScript script;
private final DateFieldScript script;
public Parse(DateScriptFieldScript script) {
public Parse(DateFieldScript script) {
this.script = script;
}

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.util.ArrayUtil;
@ -18,7 +18,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
public abstract class DoubleScriptFieldScript extends AbstractScriptFieldScript {
public abstract class DoubleFieldScript extends AbstractFieldScript {
public static final ScriptContext<Factory> CONTEXT = newContext("double_script_field", Factory.class);
static List<Whitelist> whitelist() {
@ -35,13 +35,13 @@ public abstract class DoubleScriptFieldScript extends AbstractScriptFieldScript
}
public interface LeafFactory {
DoubleScriptFieldScript newInstance(LeafReaderContext ctx);
DoubleFieldScript newInstance(LeafReaderContext ctx);
}
private double[] values = new double[1];
private int count;
public DoubleScriptFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
public DoubleFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
super(fieldName, params, searchLookup, ctx);
}
@ -80,9 +80,9 @@ public abstract class DoubleScriptFieldScript extends AbstractScriptFieldScript
}
public static class Emit {
private final DoubleScriptFieldScript script;
private final DoubleFieldScript script;
public Emit(DoubleScriptFieldScript script) {
public Emit(DoubleFieldScript script) {
this.script = script;
}

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.document.InetAddressPoint;
import org.apache.lucene.index.LeafReaderContext;
@ -26,7 +26,7 @@ import java.util.List;
import java.util.Map;
/**
* Script producing IP addresses. Unlike the other {@linkplain AbstractScriptFieldScript}s
* Script producing IP addresses. Unlike the other {@linkplain AbstractFieldScript}s
* which deal with their native java objects this converts its values to the same format
* that Lucene uses to store its fields, {@link InetAddressPoint}. There are a few compelling
* reasons to do this:
@ -39,7 +39,7 @@ import java.util.Map;
* so it saves us a lot of trouble to use the same representation.
* </ul>
*/
public abstract class IpScriptFieldScript extends AbstractScriptFieldScript {
public abstract class IpFieldScript extends AbstractFieldScript {
public static final ScriptContext<Factory> CONTEXT = newContext("ip_script_field", Factory.class);
static List<Whitelist> whitelist() {
@ -54,13 +54,13 @@ public abstract class IpScriptFieldScript extends AbstractScriptFieldScript {
}
public interface LeafFactory {
IpScriptFieldScript newInstance(LeafReaderContext ctx);
IpFieldScript newInstance(LeafReaderContext ctx);
}
private BytesRef[] values = new BytesRef[1];
private int count;
public IpScriptFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
public IpFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
super(fieldName, params, searchLookup, ctx);
}
@ -102,9 +102,9 @@ public abstract class IpScriptFieldScript extends AbstractScriptFieldScript {
}
public static class Emit {
private final IpScriptFieldScript script;
private final IpFieldScript script;
public Emit(IpScriptFieldScript script) {
public Emit(IpFieldScript script) {
this.script = script;
}

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.painless.spi.Whitelist;
@ -17,7 +17,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
public abstract class LongScriptFieldScript extends AbstractLongScriptFieldScript {
public abstract class LongFieldScript extends AbstractLongFieldScript {
public static final ScriptContext<Factory> CONTEXT = newContext("long_script_field", Factory.class);
static List<Whitelist> whitelist() {
@ -32,17 +32,17 @@ public abstract class LongScriptFieldScript extends AbstractLongScriptFieldScrip
}
public interface LeafFactory {
LongScriptFieldScript newInstance(LeafReaderContext ctx);
LongFieldScript newInstance(LeafReaderContext ctx);
}
public LongScriptFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
public LongFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
super(fieldName, params, searchLookup, ctx);
}
public static class Emit {
private final LongScriptFieldScript script;
private final LongFieldScript script;
public Emit(LongScriptFieldScript script) {
public Emit(LongFieldScript script) {
this.script = script;
}

View File

@ -24,12 +24,6 @@ import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.script.ScriptType;
import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.DateScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.LongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import java.util.List;
import java.util.Locale;
@ -91,10 +85,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper {
static final Map<String, BiFunction<Builder, BuilderContext, AbstractScriptMappedFieldType<?>>> FIELD_TYPE_RESOLVER =
org.elasticsearch.common.collect.Map.of(BooleanFieldMapper.CONTENT_TYPE, (builder, context) -> {
builder.formatAndLocaleNotSupported();
BooleanScriptFieldScript.Factory factory = builder.scriptCompiler.compile(
builder.script.getValue(),
BooleanScriptFieldScript.CONTEXT
);
BooleanFieldScript.Factory factory = builder.scriptCompiler.compile(builder.script.getValue(), BooleanFieldScript.CONTEXT);
return new ScriptBooleanMappedFieldType(
builder.buildFullName(context),
builder.script.getValue(),
@ -102,10 +93,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper {
builder.meta.getValue()
);
}, DateFieldMapper.CONTENT_TYPE, (builder, context) -> {
DateScriptFieldScript.Factory factory = builder.scriptCompiler.compile(
builder.script.getValue(),
DateScriptFieldScript.CONTEXT
);
DateFieldScript.Factory factory = builder.scriptCompiler.compile(builder.script.getValue(), DateFieldScript.CONTEXT);
String format = builder.format.getValue();
if (format == null) {
format = DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.pattern();
@ -124,10 +112,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper {
);
}, NumberType.DOUBLE.typeName(), (builder, context) -> {
builder.formatAndLocaleNotSupported();
DoubleScriptFieldScript.Factory factory = builder.scriptCompiler.compile(
builder.script.getValue(),
DoubleScriptFieldScript.CONTEXT
);
DoubleFieldScript.Factory factory = builder.scriptCompiler.compile(builder.script.getValue(), DoubleFieldScript.CONTEXT);
return new ScriptDoubleMappedFieldType(
builder.buildFullName(context),
builder.script.getValue(),
@ -136,10 +121,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper {
);
}, IpFieldMapper.CONTENT_TYPE, (builder, context) -> {
builder.formatAndLocaleNotSupported();
IpScriptFieldScript.Factory factory = builder.scriptCompiler.compile(
builder.script.getValue(),
IpScriptFieldScript.CONTEXT
);
IpFieldScript.Factory factory = builder.scriptCompiler.compile(builder.script.getValue(), IpFieldScript.CONTEXT);
return new ScriptIpMappedFieldType(
builder.buildFullName(context),
builder.script.getValue(),
@ -148,10 +130,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper {
);
}, KeywordFieldMapper.CONTENT_TYPE, (builder, context) -> {
builder.formatAndLocaleNotSupported();
StringScriptFieldScript.Factory factory = builder.scriptCompiler.compile(
builder.script.getValue(),
StringScriptFieldScript.CONTEXT
);
StringFieldScript.Factory factory = builder.scriptCompiler.compile(builder.script.getValue(), StringFieldScript.CONTEXT);
return new ScriptKeywordMappedFieldType(
builder.buildFullName(context),
builder.script.getValue(),
@ -160,10 +139,7 @@ public final class RuntimeFieldMapper extends ParametrizedFieldMapper {
);
}, NumberType.LONG.typeName(), (builder, context) -> {
builder.formatAndLocaleNotSupported();
LongScriptFieldScript.Factory factory = builder.scriptCompiler.compile(
builder.script.getValue(),
LongScriptFieldScript.CONTEXT
);
LongFieldScript.Factory factory = builder.scriptCompiler.compile(builder.script.getValue(), LongFieldScript.CONTEXT);
return new ScriptLongMappedFieldType(
builder.buildFullName(context),
builder.script.getValue(),

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.elasticsearch.painless.spi.PainlessExtension;
import org.elasticsearch.painless.spi.Whitelist;
@ -17,18 +17,18 @@ public class RuntimeFieldsPainlessExtension implements PainlessExtension {
@Override
public Map<ScriptContext<?>, List<Whitelist>> getContextWhitelists() {
return org.elasticsearch.common.collect.Map.of(
BooleanScriptFieldScript.CONTEXT,
BooleanScriptFieldScript.whitelist(),
DateScriptFieldScript.CONTEXT,
DateScriptFieldScript.whitelist(),
DoubleScriptFieldScript.CONTEXT,
DoubleScriptFieldScript.whitelist(),
IpScriptFieldScript.CONTEXT,
IpScriptFieldScript.whitelist(),
LongScriptFieldScript.CONTEXT,
LongScriptFieldScript.whitelist(),
StringScriptFieldScript.CONTEXT,
StringScriptFieldScript.whitelist()
BooleanFieldScript.CONTEXT,
BooleanFieldScript.whitelist(),
DateFieldScript.CONTEXT,
DateFieldScript.whitelist(),
DoubleFieldScript.CONTEXT,
DoubleFieldScript.whitelist(),
IpFieldScript.CONTEXT,
IpFieldScript.whitelist(),
LongFieldScript.CONTEXT,
LongFieldScript.whitelist(),
StringFieldScript.CONTEXT,
StringFieldScript.whitelist()
);
}
}

View File

@ -17,7 +17,6 @@ import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptBooleanFieldData;
import org.elasticsearch.xpack.runtimefields.query.BooleanScriptFieldExistsQuery;
import org.elasticsearch.xpack.runtimefields.query.BooleanScriptFieldTermQuery;
@ -27,8 +26,8 @@ import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
public class ScriptBooleanMappedFieldType extends AbstractScriptMappedFieldType<BooleanScriptFieldScript.LeafFactory> {
ScriptBooleanMappedFieldType(String name, Script script, BooleanScriptFieldScript.Factory scriptFactory, Map<String, String> meta) {
public class ScriptBooleanMappedFieldType extends AbstractScriptMappedFieldType<BooleanFieldScript.LeafFactory> {
ScriptBooleanMappedFieldType(String name, Script script, BooleanFieldScript.Factory scriptFactory, Map<String, String> meta) {
super(name, script, scriptFactory::newFactory, meta);
}

View File

@ -8,7 +8,6 @@ package org.elasticsearch.xpack.runtimefields.mapper;
import com.carrotsearch.hppc.LongHashSet;
import com.carrotsearch.hppc.LongSet;
import org.apache.lucene.search.Query;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.lucene.search.Queries;
@ -22,7 +21,6 @@ import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.xpack.runtimefields.DateScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptDateFieldData;
import org.elasticsearch.xpack.runtimefields.query.LongScriptFieldDistanceFeatureQuery;
import org.elasticsearch.xpack.runtimefields.query.LongScriptFieldExistsQuery;
@ -37,13 +35,13 @@ import java.util.Locale;
import java.util.Map;
import java.util.function.Supplier;
public class ScriptDateMappedFieldType extends AbstractScriptMappedFieldType<DateScriptFieldScript.LeafFactory> {
public class ScriptDateMappedFieldType extends AbstractScriptMappedFieldType<DateFieldScript.LeafFactory> {
private final DateFormatter dateTimeFormatter;
ScriptDateMappedFieldType(
String name,
Script script,
DateScriptFieldScript.Factory scriptFactory,
DateFieldScript.Factory scriptFactory,
DateFormatter dateTimeFormatter,
Map<String, String> meta
) {

View File

@ -8,7 +8,6 @@ package org.elasticsearch.xpack.runtimefields.mapper;
import com.carrotsearch.hppc.LongHashSet;
import com.carrotsearch.hppc.LongSet;
import org.apache.lucene.search.Query;
import org.elasticsearch.common.lucene.search.Queries;
import org.elasticsearch.common.time.DateMathParser;
@ -17,7 +16,6 @@ import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptDoubleFieldData;
import org.elasticsearch.xpack.runtimefields.query.DoubleScriptFieldExistsQuery;
import org.elasticsearch.xpack.runtimefields.query.DoubleScriptFieldRangeQuery;
@ -29,8 +27,8 @@ import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
public class ScriptDoubleMappedFieldType extends AbstractScriptMappedFieldType<DoubleScriptFieldScript.LeafFactory> {
ScriptDoubleMappedFieldType(String name, Script script, DoubleScriptFieldScript.Factory scriptFactory, Map<String, String> meta) {
public class ScriptDoubleMappedFieldType extends AbstractScriptMappedFieldType<DoubleFieldScript.LeafFactory> {
ScriptDoubleMappedFieldType(String name, Script script, DoubleFieldScript.Factory scriptFactory, Map<String, String> meta) {
super(name, script, scriptFactory::newFactory, meta);
}

View File

@ -22,7 +22,6 @@ import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptIpFieldData;
import org.elasticsearch.xpack.runtimefields.query.IpScriptFieldExistsQuery;
import org.elasticsearch.xpack.runtimefields.query.IpScriptFieldRangeQuery;
@ -37,8 +36,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.function.Supplier;
public final class ScriptIpMappedFieldType extends AbstractScriptMappedFieldType<IpScriptFieldScript.LeafFactory> {
ScriptIpMappedFieldType(String name, Script script, IpScriptFieldScript.Factory scriptFactory, Map<String, String> meta) {
public final class ScriptIpMappedFieldType extends AbstractScriptMappedFieldType<IpFieldScript.LeafFactory> {
ScriptIpMappedFieldType(String name, Script script, IpFieldScript.Factory scriptFactory, Map<String, String> meta) {
super(name, script, scriptFactory::newFactory, meta);
}

View File

@ -16,7 +16,6 @@ import org.elasticsearch.index.mapper.KeywordFieldMapper;
import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptStringFieldData;
import org.elasticsearch.xpack.runtimefields.query.StringScriptFieldExistsQuery;
import org.elasticsearch.xpack.runtimefields.query.StringScriptFieldFuzzyQuery;
@ -36,8 +35,8 @@ import java.util.function.Supplier;
import static java.util.stream.Collectors.toSet;
public final class ScriptKeywordMappedFieldType extends AbstractScriptMappedFieldType<StringScriptFieldScript.LeafFactory> {
ScriptKeywordMappedFieldType(String name, Script script, StringScriptFieldScript.Factory scriptFactory, Map<String, String> meta) {
public final class ScriptKeywordMappedFieldType extends AbstractScriptMappedFieldType<StringFieldScript.LeafFactory> {
ScriptKeywordMappedFieldType(String name, Script script, StringFieldScript.Factory scriptFactory, Map<String, String> meta) {
super(name, script, scriptFactory::newFactory, meta);
}

View File

@ -8,7 +8,6 @@ package org.elasticsearch.xpack.runtimefields.mapper;
import com.carrotsearch.hppc.LongHashSet;
import com.carrotsearch.hppc.LongSet;
import org.apache.lucene.search.Query;
import org.elasticsearch.common.lucene.search.Queries;
import org.elasticsearch.common.time.DateMathParser;
@ -17,7 +16,6 @@ import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.xpack.runtimefields.LongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptLongFieldData;
import org.elasticsearch.xpack.runtimefields.query.LongScriptFieldExistsQuery;
import org.elasticsearch.xpack.runtimefields.query.LongScriptFieldRangeQuery;
@ -29,8 +27,8 @@ import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
public class ScriptLongMappedFieldType extends AbstractScriptMappedFieldType<LongScriptFieldScript.LeafFactory> {
ScriptLongMappedFieldType(String name, Script script, LongScriptFieldScript.Factory scriptFactory, Map<String, String> meta) {
public class ScriptLongMappedFieldType extends AbstractScriptMappedFieldType<LongFieldScript.LeafFactory> {
ScriptLongMappedFieldType(String name, Script script, LongFieldScript.Factory scriptFactory, Map<String, String> meta) {
super(name, script, scriptFactory::newFactory, meta);
}

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.painless.spi.Whitelist;
@ -19,7 +19,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
public abstract class StringScriptFieldScript extends AbstractScriptFieldScript {
public abstract class StringFieldScript extends AbstractFieldScript {
/**
* The maximum number of chars a script should be allowed to emit.
*/
@ -41,13 +41,13 @@ public abstract class StringScriptFieldScript extends AbstractScriptFieldScript
}
public interface LeafFactory {
StringScriptFieldScript newInstance(LeafReaderContext ctx);
StringFieldScript newInstance(LeafReaderContext ctx);
}
private final List<String> results = new ArrayList<>();
private long chars;
public StringScriptFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
public StringFieldScript(String fieldName, Map<String, Object> params, SearchLookup searchLookup, LeafReaderContext ctx) {
super(fieldName, params, searchLookup, ctx);
}
@ -83,9 +83,9 @@ public abstract class StringScriptFieldScript extends AbstractScriptFieldScript
}
public static class Emit {
private final StringScriptFieldScript script;
private final StringFieldScript script;
public Emit(StringScriptFieldScript script) {
public Emit(StringFieldScript script) {
this.script = script;
}

View File

@ -8,20 +8,20 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.search.QueryVisitor;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.BooleanFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript;
/**
* Abstract base class for building queries based on {@link DoubleScriptFieldScript}.
* Abstract base class for building queries based on {@link DoubleFieldScript}.
*/
abstract class AbstractBooleanScriptFieldQuery extends AbstractScriptFieldQuery<BooleanScriptFieldScript> {
abstract class AbstractBooleanScriptFieldQuery extends AbstractScriptFieldQuery<BooleanFieldScript> {
AbstractBooleanScriptFieldQuery(Script script, BooleanScriptFieldScript.LeafFactory leafFactory, String fieldName) {
AbstractBooleanScriptFieldQuery(Script script, BooleanFieldScript.LeafFactory leafFactory, String fieldName) {
super(script, fieldName, leafFactory::newInstance);
}
@Override
protected boolean matches(BooleanScriptFieldScript scriptContext, int docId) {
protected boolean matches(BooleanFieldScript scriptContext, int docId) {
scriptContext.runForDoc(docId);
return matches(scriptContext.trues(), scriptContext.falses());
}

View File

@ -8,19 +8,19 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.search.QueryVisitor;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript;
/**
* Abstract base class for building queries based on {@link DoubleScriptFieldScript}.
* Abstract base class for building queries based on {@link DoubleFieldScript}.
*/
abstract class AbstractDoubleScriptFieldQuery extends AbstractScriptFieldQuery<DoubleScriptFieldScript> {
abstract class AbstractDoubleScriptFieldQuery extends AbstractScriptFieldQuery<DoubleFieldScript> {
AbstractDoubleScriptFieldQuery(Script script, DoubleScriptFieldScript.LeafFactory leafFactory, String fieldName) {
AbstractDoubleScriptFieldQuery(Script script, DoubleFieldScript.LeafFactory leafFactory, String fieldName) {
super(script, fieldName, leafFactory::newInstance);
}
@Override
protected boolean matches(DoubleScriptFieldScript scriptContext, int docId) {
protected boolean matches(DoubleFieldScript scriptContext, int docId) {
scriptContext.runForDoc(docId);
return matches(scriptContext.values(), scriptContext.count());
}

View File

@ -11,22 +11,22 @@ import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.net.InetAddress;
/**
* Abstract base class for building queries based on {@link StringScriptFieldScript}.
* Abstract base class for building queries based on {@link StringFieldScript}.
*/
abstract class AbstractIpScriptFieldQuery extends AbstractScriptFieldQuery<IpScriptFieldScript> {
abstract class AbstractIpScriptFieldQuery extends AbstractScriptFieldQuery<IpFieldScript> {
AbstractIpScriptFieldQuery(Script script, IpScriptFieldScript.LeafFactory leafFactory, String fieldName) {
AbstractIpScriptFieldQuery(Script script, IpFieldScript.LeafFactory leafFactory, String fieldName) {
super(script, fieldName, leafFactory::newInstance);
}
@Override
protected boolean matches(IpScriptFieldScript scriptContext, int docId) {
protected boolean matches(IpFieldScript scriptContext, int docId) {
scriptContext.runForDoc(docId);
return matches(scriptContext.values(), scriptContext.count());
}

View File

@ -9,25 +9,25 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.QueryVisitor;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.AbstractLongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.AbstractLongFieldScript;
import java.util.function.Function;
/**
* Abstract base class for building queries based on {@link AbstractLongScriptFieldScript}.
* Abstract base class for building queries based on {@link AbstractLongFieldScript}.
*/
abstract class AbstractLongScriptFieldQuery extends AbstractScriptFieldQuery<AbstractLongScriptFieldScript> {
abstract class AbstractLongScriptFieldQuery extends AbstractScriptFieldQuery<AbstractLongFieldScript> {
AbstractLongScriptFieldQuery(
Script script,
Function<LeafReaderContext, AbstractLongScriptFieldScript> scriptContextFunction,
Function<LeafReaderContext, AbstractLongFieldScript> scriptContextFunction,
String fieldName
) {
super(script, fieldName, scriptContextFunction);
}
@Override
protected boolean matches(AbstractLongScriptFieldScript scriptContext, int docId) {
protected boolean matches(AbstractLongFieldScript scriptContext, int docId) {
scriptContext.runForDoc(docId);
return AbstractLongScriptFieldQuery.this.matches(scriptContext.values(), scriptContext.count());
}

View File

@ -17,7 +17,7 @@ import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.TwoPhaseIterator;
import org.apache.lucene.search.Weight;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.AbstractScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.AbstractFieldScript;
import java.io.IOException;
import java.util.Objects;
@ -26,7 +26,7 @@ import java.util.function.Function;
/**
* Abstract base class for building queries based on script fields.
*/
abstract class AbstractScriptFieldQuery<S extends AbstractScriptFieldScript> extends Query {
abstract class AbstractScriptFieldQuery<S extends AbstractFieldScript> extends Query {
/**
* We don't have the infrastructure to estimate the match cost of a script
* so we just use a big number.

View File

@ -10,7 +10,7 @@ import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.automaton.ByteRunAutomaton;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.List;
@ -20,7 +20,7 @@ public abstract class AbstractStringScriptFieldAutomatonQuery extends AbstractSt
public AbstractStringScriptFieldAutomatonQuery(
Script script,
StringScriptFieldScript.LeafFactory leafFactory,
StringFieldScript.LeafFactory leafFactory,
String fieldName,
ByteRunAutomaton automaton
) {

View File

@ -7,21 +7,21 @@
package org.elasticsearch.xpack.runtimefields.query;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.List;
/**
* Abstract base class for building queries based on {@link StringScriptFieldScript}.
* Abstract base class for building queries based on {@link StringFieldScript}.
*/
abstract class AbstractStringScriptFieldQuery extends AbstractScriptFieldQuery<StringScriptFieldScript> {
abstract class AbstractStringScriptFieldQuery extends AbstractScriptFieldQuery<StringFieldScript> {
AbstractStringScriptFieldQuery(Script script, StringScriptFieldScript.LeafFactory leafFactory, String fieldName) {
AbstractStringScriptFieldQuery(Script script, StringFieldScript.LeafFactory leafFactory, String fieldName) {
super(script, fieldName, leafFactory::newInstance);
}
@Override
protected final boolean matches(StringScriptFieldScript scriptContext, int docId) {
protected final boolean matches(StringFieldScript scriptContext, int docId) {
return matches(scriptContext.resultsForDoc(docId));
}

View File

@ -7,10 +7,10 @@
package org.elasticsearch.xpack.runtimefields.query;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.BooleanFieldScript;
public class BooleanScriptFieldExistsQuery extends AbstractBooleanScriptFieldQuery {
public BooleanScriptFieldExistsQuery(Script script, BooleanScriptFieldScript.LeafFactory leafFactory, String fieldName) {
public BooleanScriptFieldExistsQuery(Script script, BooleanFieldScript.LeafFactory leafFactory, String fieldName) {
super(script, leafFactory, fieldName);
}

View File

@ -7,14 +7,14 @@
package org.elasticsearch.xpack.runtimefields.query;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.BooleanFieldScript;
import java.util.Objects;
public class BooleanScriptFieldTermQuery extends AbstractBooleanScriptFieldQuery {
private final boolean term;
public BooleanScriptFieldTermQuery(Script script, BooleanScriptFieldScript.LeafFactory leafFactory, String fieldName, boolean term) {
public BooleanScriptFieldTermQuery(Script script, BooleanFieldScript.LeafFactory leafFactory, String fieldName, boolean term) {
super(script, leafFactory, fieldName);
this.term = term;
}

View File

@ -7,10 +7,10 @@
package org.elasticsearch.xpack.runtimefields.query;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript;
public class DoubleScriptFieldExistsQuery extends AbstractDoubleScriptFieldQuery {
public DoubleScriptFieldExistsQuery(Script script, DoubleScriptFieldScript.LeafFactory leafFactory, String fieldName) {
public DoubleScriptFieldExistsQuery(Script script, DoubleFieldScript.LeafFactory leafFactory, String fieldName) {
super(script, leafFactory, fieldName);
}

View File

@ -7,7 +7,7 @@
package org.elasticsearch.xpack.runtimefields.query;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript;
import java.util.Objects;
@ -17,7 +17,7 @@ public class DoubleScriptFieldRangeQuery extends AbstractDoubleScriptFieldQuery
public DoubleScriptFieldRangeQuery(
Script script,
DoubleScriptFieldScript.LeafFactory leafFactory,
DoubleFieldScript.LeafFactory leafFactory,
String fieldName,
double lowerValue,
double upperValue

View File

@ -7,14 +7,14 @@
package org.elasticsearch.xpack.runtimefields.query;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript;
import java.util.Objects;
public class DoubleScriptFieldTermQuery extends AbstractDoubleScriptFieldQuery {
private final double term;
public DoubleScriptFieldTermQuery(Script script, DoubleScriptFieldScript.LeafFactory leafFactory, String fieldName, double term) {
public DoubleScriptFieldTermQuery(Script script, DoubleFieldScript.LeafFactory leafFactory, String fieldName, double term) {
super(script, leafFactory, fieldName);
this.term = term;
}

View File

@ -9,9 +9,8 @@ package org.elasticsearch.xpack.runtimefields.query;
import com.carrotsearch.hppc.LongSet;
import com.carrotsearch.hppc.cursors.LongCursor;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript;
import java.util.Arrays;
import java.util.Objects;
@ -23,7 +22,7 @@ public class DoubleScriptFieldTermsQuery extends AbstractDoubleScriptFieldQuery
* Build the query.
* @param terms The terms converted to a long with {@link Double#doubleToLongBits(double)}.
*/
public DoubleScriptFieldTermsQuery(Script script, DoubleScriptFieldScript.LeafFactory leafFactory, String fieldName, LongSet terms) {
public DoubleScriptFieldTermsQuery(Script script, DoubleFieldScript.LeafFactory leafFactory, String fieldName, LongSet terms) {
super(script, leafFactory, fieldName);
this.terms = terms;
}

View File

@ -8,10 +8,10 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript;
public class IpScriptFieldExistsQuery extends AbstractIpScriptFieldQuery {
public IpScriptFieldExistsQuery(Script script, IpScriptFieldScript.LeafFactory leafFactory, String fieldName) {
public IpScriptFieldExistsQuery(Script script, IpFieldScript.LeafFactory leafFactory, String fieldName) {
super(script, leafFactory, fieldName);
}

View File

@ -9,7 +9,7 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.network.InetAddresses;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript;
import java.net.InetAddress;
import java.util.Objects;
@ -18,13 +18,7 @@ public class IpScriptFieldRangeQuery extends AbstractIpScriptFieldQuery {
private final BytesRef lower;
private final BytesRef upper;
public IpScriptFieldRangeQuery(
Script script,
IpScriptFieldScript.LeafFactory leafFactory,
String fieldName,
BytesRef lower,
BytesRef upper
) {
public IpScriptFieldRangeQuery(Script script, IpFieldScript.LeafFactory leafFactory, String fieldName, BytesRef lower, BytesRef upper) {
super(script, leafFactory, fieldName);
this.lower = lower;
this.upper = upper;

View File

@ -9,7 +9,7 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.network.InetAddresses;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript;
import java.net.InetAddress;
import java.util.Objects;
@ -17,7 +17,7 @@ import java.util.Objects;
public class IpScriptFieldTermQuery extends AbstractIpScriptFieldQuery {
private final BytesRef term;
public IpScriptFieldTermQuery(Script script, IpScriptFieldScript.LeafFactory leafFactory, String fieldName, BytesRef term) {
public IpScriptFieldTermQuery(Script script, IpFieldScript.LeafFactory leafFactory, String fieldName, BytesRef term) {
super(script, leafFactory, fieldName);
this.term = term;
}

View File

@ -10,14 +10,14 @@ import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.network.InetAddresses;
import org.elasticsearch.common.util.BytesRefHash;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript;
import java.util.Objects;
public class IpScriptFieldTermsQuery extends AbstractIpScriptFieldQuery {
private final BytesRefHash terms;
public IpScriptFieldTermsQuery(Script script, IpScriptFieldScript.LeafFactory leafFactory, String fieldName, BytesRefHash terms) {
public IpScriptFieldTermsQuery(Script script, IpFieldScript.LeafFactory leafFactory, String fieldName, BytesRefHash terms) {
super(script, leafFactory, fieldName);
this.terms = terms;
}

View File

@ -17,21 +17,21 @@ import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.TwoPhaseIterator;
import org.apache.lucene.search.Weight;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.AbstractLongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.AbstractLongFieldScript;
import java.io.IOException;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
public final class LongScriptFieldDistanceFeatureQuery extends AbstractScriptFieldQuery<AbstractLongScriptFieldScript> {
public final class LongScriptFieldDistanceFeatureQuery extends AbstractScriptFieldQuery<AbstractLongFieldScript> {
private final long origin;
private final long pivot;
private final float boost;
public LongScriptFieldDistanceFeatureQuery(
Script script,
Function<LeafReaderContext, AbstractLongScriptFieldScript> leafFactory,
Function<LeafReaderContext, AbstractLongFieldScript> leafFactory,
String fieldName,
long origin,
long pivot,
@ -44,7 +44,7 @@ public final class LongScriptFieldDistanceFeatureQuery extends AbstractScriptFie
}
@Override
protected boolean matches(AbstractLongScriptFieldScript scriptContext, int docId) {
protected boolean matches(AbstractLongFieldScript scriptContext, int docId) {
scriptContext.runForDoc(docId);
return scriptContext.count() > 0;
}
@ -67,7 +67,7 @@ public final class LongScriptFieldDistanceFeatureQuery extends AbstractScriptFie
@Override
public Explanation explain(LeafReaderContext context, int doc) {
AbstractLongScriptFieldScript script = scriptContextFunction().apply(context);
AbstractLongFieldScript script = scriptContextFunction().apply(context);
script.runForDoc(doc);
long value = valueWithMinAbsoluteDistance(script);
float weight = LongScriptFieldDistanceFeatureQuery.this.boost * boost;
@ -85,12 +85,12 @@ public final class LongScriptFieldDistanceFeatureQuery extends AbstractScriptFie
}
private class DistanceScorer extends Scorer {
private final AbstractLongScriptFieldScript script;
private final AbstractLongFieldScript script;
private final TwoPhaseIterator twoPhase;
private final DocIdSetIterator disi;
private final float weight;
protected DistanceScorer(Weight weight, AbstractLongScriptFieldScript script, int maxDoc, float boost) {
protected DistanceScorer(Weight weight, AbstractLongFieldScript script, int maxDoc, float boost) {
super(weight);
this.script = script;
twoPhase = new TwoPhaseIterator(DocIdSetIterator.all(maxDoc)) {
@ -137,7 +137,7 @@ public final class LongScriptFieldDistanceFeatureQuery extends AbstractScriptFie
}
}
long minAbsoluteDistance(AbstractLongScriptFieldScript script) {
long minAbsoluteDistance(AbstractLongFieldScript script) {
long minDistance = Long.MAX_VALUE;
for (int i = 0; i < script.count(); i++) {
minDistance = Math.min(minDistance, distanceFor(script.values()[i]));
@ -145,7 +145,7 @@ public final class LongScriptFieldDistanceFeatureQuery extends AbstractScriptFie
return minDistance;
}
long valueWithMinAbsoluteDistance(AbstractLongScriptFieldScript script) {
long valueWithMinAbsoluteDistance(AbstractLongFieldScript script) {
long minDistance = Long.MAX_VALUE;
long minDistanceValue = Long.MAX_VALUE;
for (int i = 0; i < script.count(); i++) {

View File

@ -8,16 +8,12 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.AbstractLongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.AbstractLongFieldScript;
import java.util.function.Function;
public class LongScriptFieldExistsQuery extends AbstractLongScriptFieldQuery {
public LongScriptFieldExistsQuery(
Script script,
Function<LeafReaderContext, AbstractLongScriptFieldScript> leafFactory,
String fieldName
) {
public LongScriptFieldExistsQuery(Script script, Function<LeafReaderContext, AbstractLongFieldScript> leafFactory, String fieldName) {
super(script, leafFactory, fieldName);
}

View File

@ -8,7 +8,7 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.AbstractLongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.AbstractLongFieldScript;
import java.util.Objects;
import java.util.function.Function;
@ -19,7 +19,7 @@ public class LongScriptFieldRangeQuery extends AbstractLongScriptFieldQuery {
public LongScriptFieldRangeQuery(
Script script,
Function<LeafReaderContext, AbstractLongScriptFieldScript> leafFactory,
Function<LeafReaderContext, AbstractLongFieldScript> leafFactory,
String fieldName,
long lowerValue,
long upperValue

View File

@ -8,7 +8,7 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.AbstractLongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.AbstractLongFieldScript;
import java.util.Objects;
import java.util.function.Function;
@ -18,7 +18,7 @@ public class LongScriptFieldTermQuery extends AbstractLongScriptFieldQuery {
public LongScriptFieldTermQuery(
Script script,
Function<LeafReaderContext, AbstractLongScriptFieldScript> leafFactory,
Function<LeafReaderContext, AbstractLongFieldScript> leafFactory,
String fieldName,
long term
) {

View File

@ -9,7 +9,7 @@ package org.elasticsearch.xpack.runtimefields.query;
import com.carrotsearch.hppc.LongSet;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.AbstractLongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.AbstractLongFieldScript;
import java.util.Objects;
import java.util.function.Function;
@ -19,7 +19,7 @@ public class LongScriptFieldTermsQuery extends AbstractLongScriptFieldQuery {
public LongScriptFieldTermsQuery(
Script script,
Function<LeafReaderContext, AbstractLongScriptFieldScript> leafFactory,
Function<LeafReaderContext, AbstractLongFieldScript> leafFactory,
String fieldName,
LongSet terms
) {

View File

@ -7,12 +7,12 @@
package org.elasticsearch.xpack.runtimefields.query;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.List;
public class StringScriptFieldExistsQuery extends AbstractStringScriptFieldQuery {
public StringScriptFieldExistsQuery(Script script, StringScriptFieldScript.LeafFactory leafFactory, String fieldName) {
public StringScriptFieldExistsQuery(Script script, StringFieldScript.LeafFactory leafFactory, String fieldName) {
super(script, leafFactory, fieldName);
}

View File

@ -10,14 +10,14 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.util.automaton.ByteRunAutomaton;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.Objects;
public class StringScriptFieldFuzzyQuery extends AbstractStringScriptFieldAutomatonQuery {
public static StringScriptFieldFuzzyQuery build(
Script script,
StringScriptFieldScript.LeafFactory leafFactory,
StringFieldScript.LeafFactory leafFactory,
String fieldName,
String term,
int maxEdits,
@ -34,7 +34,7 @@ public class StringScriptFieldFuzzyQuery extends AbstractStringScriptFieldAutoma
private StringScriptFieldFuzzyQuery(
Script script,
StringScriptFieldScript.LeafFactory leafFactory,
StringFieldScript.LeafFactory leafFactory,
String fieldName,
ByteRunAutomaton automaton,
FuzzyQuery delegate

View File

@ -11,7 +11,7 @@ import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.automaton.ByteRunAutomaton;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.List;
import java.util.Objects;
@ -19,7 +19,7 @@ import java.util.Objects;
public class StringScriptFieldPrefixQuery extends AbstractStringScriptFieldQuery {
private final String prefix;
public StringScriptFieldPrefixQuery(Script script, StringScriptFieldScript.LeafFactory leafFactory, String fieldName, String prefix) {
public StringScriptFieldPrefixQuery(Script script, StringFieldScript.LeafFactory leafFactory, String fieldName, String prefix) {
super(script, leafFactory, fieldName);
this.prefix = Objects.requireNonNull(prefix);
}

View File

@ -11,7 +11,7 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.automaton.Automata;
import org.apache.lucene.util.automaton.ByteRunAutomaton;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.List;
import java.util.Objects;
@ -24,7 +24,7 @@ public class StringScriptFieldRangeQuery extends AbstractStringScriptFieldQuery
public StringScriptFieldRangeQuery(
Script script,
StringScriptFieldScript.LeafFactory leafFactory,
StringFieldScript.LeafFactory leafFactory,
String fieldName,
String lowerValue,
String upperValue,

View File

@ -9,7 +9,7 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.util.automaton.ByteRunAutomaton;
import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.Objects;
@ -19,7 +19,7 @@ public class StringScriptFieldRegexpQuery extends AbstractStringScriptFieldAutom
public StringScriptFieldRegexpQuery(
Script script,
StringScriptFieldScript.LeafFactory leafFactory,
StringFieldScript.LeafFactory leafFactory,
String fieldName,
String pattern,
int flags,

View File

@ -9,7 +9,7 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.QueryVisitor;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.List;
import java.util.Objects;
@ -17,7 +17,7 @@ import java.util.Objects;
public class StringScriptFieldTermQuery extends AbstractStringScriptFieldQuery {
private final String term;
public StringScriptFieldTermQuery(Script script, StringScriptFieldScript.LeafFactory leafFactory, String fieldName, String term) {
public StringScriptFieldTermQuery(Script script, StringFieldScript.LeafFactory leafFactory, String fieldName, String term) {
super(script, leafFactory, fieldName);
this.term = Objects.requireNonNull(term);
}

View File

@ -9,7 +9,7 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.QueryVisitor;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.List;
import java.util.Objects;
@ -18,12 +18,7 @@ import java.util.Set;
public class StringScriptFieldTermsQuery extends AbstractStringScriptFieldQuery {
private final Set<String> terms;
public StringScriptFieldTermsQuery(
Script script,
StringScriptFieldScript.LeafFactory leafFactory,
String fieldName,
Set<String> terms
) {
public StringScriptFieldTermsQuery(Script script, StringFieldScript.LeafFactory leafFactory, String fieldName, Set<String> terms) {
super(script, leafFactory, fieldName);
this.terms = terms;
}

View File

@ -10,19 +10,14 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.search.WildcardQuery;
import org.apache.lucene.util.automaton.ByteRunAutomaton;
import org.elasticsearch.script.Script;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.Objects;
public class StringScriptFieldWildcardQuery extends AbstractStringScriptFieldAutomatonQuery {
private final String pattern;
public StringScriptFieldWildcardQuery(
Script script,
StringScriptFieldScript.LeafFactory leafFactory,
String fieldName,
String pattern
) {
public StringScriptFieldWildcardQuery(Script script, StringFieldScript.LeafFactory leafFactory, String fieldName, String pattern) {
super(
script,
leafFactory,

View File

@ -1 +1 @@
org.elasticsearch.xpack.runtimefields.RuntimeFieldsPainlessExtension
org.elasticsearch.xpack.runtimefields.mapper.RuntimeFieldsPainlessExtension

View File

@ -7,15 +7,15 @@
# The whitelist for boolean-valued runtime fields
# These two whitelists are required for painless to find the classes
class org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript @no_import {
class org.elasticsearch.xpack.runtimefields.mapper.BooleanFieldScript @no_import {
}
class org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript$Factory @no_import {
class org.elasticsearch.xpack.runtimefields.mapper.BooleanFieldScript$Factory @no_import {
}
static_import {
# 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
void emit(org.elasticsearch.xpack.runtimefields.mapper.BooleanFieldScript, boolean) bound_to org.elasticsearch.xpack.runtimefields.mapper.BooleanFieldScript$Emit
# Parse a value from the source to a boolean
boolean parse(def) from_class org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript
boolean parse(def) from_class org.elasticsearch.xpack.runtimefields.mapper.BooleanFieldScript
}

View File

@ -7,18 +7,18 @@
# The whitelist for date-valued runtime fields
# These two whitelists are required for painless to find the classes
class org.elasticsearch.xpack.runtimefields.DateScriptFieldScript @no_import {
class org.elasticsearch.xpack.runtimefields.mapper.DateFieldScript @no_import {
}
class org.elasticsearch.xpack.runtimefields.DateScriptFieldScript$Factory @no_import {
class org.elasticsearch.xpack.runtimefields.mapper.DateFieldScript$Factory @no_import {
}
static_import {
# 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
void emit(org.elasticsearch.xpack.runtimefields.mapper.DateFieldScript, long) bound_to org.elasticsearch.xpack.runtimefields.mapper.DateFieldScript$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
long parse(org.elasticsearch.xpack.runtimefields.mapper.DateFieldScript, def) bound_to org.elasticsearch.xpack.runtimefields.mapper.DateFieldScript$Parse
# Add an easy method to convert temporalAccessors to millis since epoch.
long toEpochMilli(java.time.temporal.TemporalAccessor) from_class org.elasticsearch.xpack.runtimefields.DateScriptFieldScript
long toEpochMilli(java.time.temporal.TemporalAccessor) from_class org.elasticsearch.xpack.runtimefields.mapper.DateFieldScript
}

View File

@ -7,13 +7,13 @@
# The whitelist for double-valued runtime fields
# These two whitelists are required for painless to find the classes
class org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript @no_import {
class org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript @no_import {
}
class org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript$Factory @no_import {
class org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript$Factory @no_import {
}
static_import {
# 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
void emit(org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript, double) bound_to org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript$Emit
}

View File

@ -7,12 +7,12 @@
# The whitelist for ip-valued runtime fields
# These two whitelists are required for painless to find the classes
class org.elasticsearch.xpack.runtimefields.IpScriptFieldScript @no_import {
class org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript @no_import {
}
class org.elasticsearch.xpack.runtimefields.IpScriptFieldScript$Factory @no_import {
class org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript$Factory @no_import {
}
static_import {
# 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
void emit(org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript, String) bound_to org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript$Emit
}

View File

@ -7,12 +7,12 @@
# The whitelist for long-valued runtime fields
# These two whitelists are required for painless to find the classes
class org.elasticsearch.xpack.runtimefields.LongScriptFieldScript @no_import {
class org.elasticsearch.xpack.runtimefields.mapper.LongFieldScript @no_import {
}
class org.elasticsearch.xpack.runtimefields.LongScriptFieldScript$Factory @no_import {
class org.elasticsearch.xpack.runtimefields.mapper.LongFieldScript$Factory @no_import {
}
static_import {
# 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
void emit(org.elasticsearch.xpack.runtimefields.mapper.LongFieldScript, long) bound_to org.elasticsearch.xpack.runtimefields.mapper.LongFieldScript$Emit
}

View File

@ -7,12 +7,12 @@
# The whitelist for string-valued runtime fields
# These two whitelists are required for painless to find the classes
class org.elasticsearch.xpack.runtimefields.StringScriptFieldScript @no_import {
class org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript @no_import {
}
class org.elasticsearch.xpack.runtimefields.StringScriptFieldScript$Factory @no_import {
class org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript$Factory @no_import {
}
static_import {
# 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
void emit(org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript, String) bound_to org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript$Emit
}

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.DirectoryReader;
@ -19,8 +19,8 @@ import java.io.IOException;
import static org.mockito.Mockito.mock;
public class BooleanScriptFieldScriptTests extends ScriptFieldScriptTestCase<BooleanScriptFieldScript.Factory> {
public static final BooleanScriptFieldScript.Factory DUMMY = (fieldName, params, lookup) -> ctx -> new BooleanScriptFieldScript(
public class BooleanFieldScriptTests extends FieldScriptTestCase<BooleanFieldScript.Factory> {
public static final BooleanFieldScript.Factory DUMMY = (fieldName, params, lookup) -> ctx -> new BooleanFieldScript(
fieldName,
params,
lookup,
@ -33,12 +33,12 @@ public class BooleanScriptFieldScriptTests extends ScriptFieldScriptTestCase<Boo
};
@Override
protected ScriptContext<BooleanScriptFieldScript.Factory> context() {
return BooleanScriptFieldScript.CONTEXT;
protected ScriptContext<BooleanFieldScript.Factory> context() {
return BooleanFieldScript.CONTEXT;
}
@Override
protected BooleanScriptFieldScript.Factory dummyScript() {
protected BooleanFieldScript.Factory dummyScript() {
return DUMMY;
}
@ -46,7 +46,7 @@ public class BooleanScriptFieldScriptTests extends ScriptFieldScriptTestCase<Boo
try (Directory directory = newDirectory(); RandomIndexWriter iw = new RandomIndexWriter(random(), directory)) {
iw.addDocument(org.elasticsearch.common.collect.List.of(new StoredField("_source", new BytesRef("{}"))));
try (DirectoryReader reader = iw.getReader()) {
BooleanScriptFieldScript script = new BooleanScriptFieldScript(
BooleanFieldScript script = new BooleanFieldScript(
"test",
org.elasticsearch.common.collect.Map.of(),
new SearchLookup(mock(MapperService.class), (ft, lookup) -> null, null),
@ -54,7 +54,7 @@ public class BooleanScriptFieldScriptTests extends ScriptFieldScriptTestCase<Boo
) {
@Override
public void execute() {
for (int i = 0; i <= AbstractScriptFieldScript.MAX_VALUES * 1000; i++) {
for (int i = 0; i <= AbstractFieldScript.MAX_VALUES * 1000; i++) {
emit(i % 2 == 0);
}
}

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.DirectoryReader;
@ -21,8 +21,8 @@ import java.io.IOException;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.mock;
public class DateScriptFieldScriptTests extends ScriptFieldScriptTestCase<DateScriptFieldScript.Factory> {
public static final DateScriptFieldScript.Factory DUMMY = (fieldName, params, lookup, formatter) -> ctx -> new DateScriptFieldScript(
public class DateFieldScriptTests extends FieldScriptTestCase<DateFieldScript.Factory> {
public static final DateFieldScript.Factory DUMMY = (fieldName, params, lookup, formatter) -> ctx -> new DateFieldScript(
fieldName,
params,
lookup,
@ -36,12 +36,12 @@ public class DateScriptFieldScriptTests extends ScriptFieldScriptTestCase<DateSc
};
@Override
protected ScriptContext<DateScriptFieldScript.Factory> context() {
return DateScriptFieldScript.CONTEXT;
protected ScriptContext<DateFieldScript.Factory> context() {
return DateFieldScript.CONTEXT;
}
@Override
protected DateScriptFieldScript.Factory dummyScript() {
protected DateFieldScript.Factory dummyScript() {
return DUMMY;
}
@ -49,7 +49,7 @@ public class DateScriptFieldScriptTests extends ScriptFieldScriptTestCase<DateSc
try (Directory directory = newDirectory(); RandomIndexWriter iw = new RandomIndexWriter(random(), directory)) {
iw.addDocument(org.elasticsearch.common.collect.List.of(new StoredField("_source", new BytesRef("{}"))));
try (DirectoryReader reader = iw.getReader()) {
DateScriptFieldScript script = new DateScriptFieldScript(
DateFieldScript script = new DateFieldScript(
"test",
org.elasticsearch.common.collect.Map.of(),
new SearchLookup(mock(MapperService.class), (ft, lookup) -> null, null),
@ -58,7 +58,7 @@ public class DateScriptFieldScriptTests extends ScriptFieldScriptTestCase<DateSc
) {
@Override
public void execute() {
for (int i = 0; i <= AbstractScriptFieldScript.MAX_VALUES; i++) {
for (int i = 0; i <= AbstractFieldScript.MAX_VALUES; i++) {
emit(0);
}
}

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.DirectoryReader;
@ -20,8 +20,8 @@ import java.io.IOException;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.mock;
public class DoubleScriptFieldScriptTests extends ScriptFieldScriptTestCase<DoubleScriptFieldScript.Factory> {
public static final DoubleScriptFieldScript.Factory DUMMY = (fieldName, params, lookup) -> ctx -> new DoubleScriptFieldScript(
public class DoubleFieldScriptTests extends FieldScriptTestCase<DoubleFieldScript.Factory> {
public static final DoubleFieldScript.Factory DUMMY = (fieldName, params, lookup) -> ctx -> new DoubleFieldScript(
fieldName,
params,
lookup,
@ -34,12 +34,12 @@ public class DoubleScriptFieldScriptTests extends ScriptFieldScriptTestCase<Doub
};
@Override
protected ScriptContext<DoubleScriptFieldScript.Factory> context() {
return DoubleScriptFieldScript.CONTEXT;
protected ScriptContext<DoubleFieldScript.Factory> context() {
return DoubleFieldScript.CONTEXT;
}
@Override
protected DoubleScriptFieldScript.Factory dummyScript() {
protected DoubleFieldScript.Factory dummyScript() {
return DUMMY;
}
@ -47,7 +47,7 @@ public class DoubleScriptFieldScriptTests extends ScriptFieldScriptTestCase<Doub
try (Directory directory = newDirectory(); RandomIndexWriter iw = new RandomIndexWriter(random(), directory)) {
iw.addDocument(org.elasticsearch.common.collect.List.of(new StoredField("_source", new BytesRef("{}"))));
try (DirectoryReader reader = iw.getReader()) {
DoubleScriptFieldScript script = new DoubleScriptFieldScript(
DoubleFieldScript script = new DoubleFieldScript(
"test",
org.elasticsearch.common.collect.Map.of(),
new SearchLookup(mock(MapperService.class), (ft, lookup) -> null, null),
@ -55,7 +55,7 @@ public class DoubleScriptFieldScriptTests extends ScriptFieldScriptTestCase<Doub
) {
@Override
public void execute() {
for (int i = 0; i <= AbstractScriptFieldScript.MAX_VALUES; i++) {
for (int i = 0; i <= AbstractFieldScript.MAX_VALUES; i++) {
emit(1.0);
}
}

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptContext;
@ -15,7 +15,7 @@ import org.elasticsearch.test.ESTestCase;
import java.io.IOException;
import java.util.Collections;
public abstract class ScriptFieldScriptTestCase<T> extends ESTestCase {
public abstract class FieldScriptTestCase<T> extends ESTestCase {
protected abstract ScriptContext<T> context();
protected abstract T dummyScript();

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.DirectoryReader;
@ -20,8 +20,8 @@ import java.io.IOException;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.mock;
public class IpScriptFieldScriptTests extends ScriptFieldScriptTestCase<IpScriptFieldScript.Factory> {
public static final IpScriptFieldScript.Factory DUMMY = (fieldName, params, lookup) -> ctx -> new IpScriptFieldScript(
public class IpFieldScriptTests extends FieldScriptTestCase<IpFieldScript.Factory> {
public static final IpFieldScript.Factory DUMMY = (fieldName, params, lookup) -> ctx -> new IpFieldScript(
fieldName,
params,
lookup,
@ -34,12 +34,12 @@ public class IpScriptFieldScriptTests extends ScriptFieldScriptTestCase<IpScript
};
@Override
protected ScriptContext<IpScriptFieldScript.Factory> context() {
return IpScriptFieldScript.CONTEXT;
protected ScriptContext<IpFieldScript.Factory> context() {
return IpFieldScript.CONTEXT;
}
@Override
protected IpScriptFieldScript.Factory dummyScript() {
protected IpFieldScript.Factory dummyScript() {
return DUMMY;
}
@ -47,7 +47,7 @@ public class IpScriptFieldScriptTests extends ScriptFieldScriptTestCase<IpScript
try (Directory directory = newDirectory(); RandomIndexWriter iw = new RandomIndexWriter(random(), directory)) {
iw.addDocument(org.elasticsearch.common.collect.List.of(new StoredField("_source", new BytesRef("{}"))));
try (DirectoryReader reader = iw.getReader()) {
IpScriptFieldScript script = new IpScriptFieldScript(
IpFieldScript script = new IpFieldScript(
"test",
org.elasticsearch.common.collect.Map.of(),
new SearchLookup(mock(MapperService.class), (ft, lookup) -> null, null),
@ -55,7 +55,7 @@ public class IpScriptFieldScriptTests extends ScriptFieldScriptTestCase<IpScript
) {
@Override
public void execute() {
for (int i = 0; i <= AbstractScriptFieldScript.MAX_VALUES; i++) {
for (int i = 0; i <= AbstractFieldScript.MAX_VALUES; i++) {
emit("192.168.0.1");
}
}

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.DirectoryReader;
@ -20,8 +20,8 @@ import java.io.IOException;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.mock;
public class LongScriptFieldScriptTests extends ScriptFieldScriptTestCase<LongScriptFieldScript.Factory> {
public static final LongScriptFieldScript.Factory DUMMY = (fieldName, params, lookup) -> ctx -> new LongScriptFieldScript(
public class LongFieldScriptTests extends FieldScriptTestCase<LongFieldScript.Factory> {
public static final LongFieldScript.Factory DUMMY = (fieldName, params, lookup) -> ctx -> new LongFieldScript(
fieldName,
params,
lookup,
@ -34,12 +34,12 @@ public class LongScriptFieldScriptTests extends ScriptFieldScriptTestCase<LongSc
};
@Override
protected ScriptContext<LongScriptFieldScript.Factory> context() {
return LongScriptFieldScript.CONTEXT;
protected ScriptContext<LongFieldScript.Factory> context() {
return LongFieldScript.CONTEXT;
}
@Override
protected LongScriptFieldScript.Factory dummyScript() {
protected LongFieldScript.Factory dummyScript() {
return DUMMY;
}
@ -47,7 +47,7 @@ public class LongScriptFieldScriptTests extends ScriptFieldScriptTestCase<LongSc
try (Directory directory = newDirectory(); RandomIndexWriter iw = new RandomIndexWriter(random(), directory)) {
iw.addDocument(org.elasticsearch.common.collect.List.of(new StoredField("_source", new BytesRef("{}"))));
try (DirectoryReader reader = iw.getReader()) {
LongScriptFieldScript script = new LongScriptFieldScript(
LongFieldScript script = new LongFieldScript(
"test",
org.elasticsearch.common.collect.Map.of(),
new SearchLookup(mock(MapperService.class), (ft, lookup) -> null, null),
@ -55,7 +55,7 @@ public class LongScriptFieldScriptTests extends ScriptFieldScriptTestCase<LongSc
) {
@Override
public void execute() {
for (int i = 0; i <= AbstractScriptFieldScript.MAX_VALUES; i++) {
for (int i = 0; i <= AbstractFieldScript.MAX_VALUES; i++) {
emit(0);
}
}

View File

@ -29,20 +29,7 @@ import org.elasticsearch.plugins.ScriptPlugin;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.script.ScriptEngine;
import org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScriptTests;
import org.elasticsearch.xpack.runtimefields.DateScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.DateScriptFieldScriptTests;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScriptTests;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScriptTests;
import org.elasticsearch.xpack.runtimefields.LongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.LongScriptFieldScriptTests;
import org.elasticsearch.xpack.runtimefields.RuntimeFields;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScriptTests;
import org.elasticsearch.xpack.runtimefields.TestScriptEngine;
import java.io.IOException;
import java.util.Arrays;
@ -320,7 +307,7 @@ public class RuntimeFieldMapperTests extends MapperTestCase {
field -> new ScriptKeywordMappedFieldType(
field,
new Script(""),
mock(StringScriptFieldScript.Factory.class),
mock(StringFieldScript.Factory.class),
Collections.emptyMap()
),
(fieldType, searchLookupSupplier) -> indexFieldDataService.getForField(fieldType, "index", searchLookupSupplier)
@ -372,35 +359,35 @@ public class RuntimeFieldMapperTests extends MapperTestCase {
return new TestScriptEngine() {
@Override
protected Object buildScriptFactory(ScriptContext<?> context) {
if (context == BooleanScriptFieldScript.CONTEXT) {
return BooleanScriptFieldScriptTests.DUMMY;
if (context == BooleanFieldScript.CONTEXT) {
return BooleanFieldScriptTests.DUMMY;
}
if (context == DateScriptFieldScript.CONTEXT) {
return DateScriptFieldScriptTests.DUMMY;
if (context == DateFieldScript.CONTEXT) {
return DateFieldScriptTests.DUMMY;
}
if (context == DoubleScriptFieldScript.CONTEXT) {
return DoubleScriptFieldScriptTests.DUMMY;
if (context == DoubleFieldScript.CONTEXT) {
return DoubleFieldScriptTests.DUMMY;
}
if (context == IpScriptFieldScript.CONTEXT) {
return IpScriptFieldScriptTests.DUMMY;
if (context == IpFieldScript.CONTEXT) {
return IpFieldScriptTests.DUMMY;
}
if (context == LongScriptFieldScript.CONTEXT) {
return LongScriptFieldScriptTests.DUMMY;
if (context == LongFieldScript.CONTEXT) {
return LongFieldScriptTests.DUMMY;
}
if (context == StringScriptFieldScript.CONTEXT) {
return StringScriptFieldScriptTests.DUMMY;
if (context == StringFieldScript.CONTEXT) {
return StringFieldScriptTests.DUMMY;
}
throw new IllegalArgumentException("Unsupported context: " + context);
};
public Set<ScriptContext<?>> getSupportedContexts() {
return org.elasticsearch.common.collect.Set.of(
BooleanScriptFieldScript.CONTEXT,
DateScriptFieldScript.CONTEXT,
DoubleScriptFieldScript.CONTEXT,
IpScriptFieldScript.CONTEXT,
StringScriptFieldScript.CONTEXT,
LongScriptFieldScript.CONTEXT
BooleanFieldScript.CONTEXT,
DateFieldScript.CONTEXT,
DoubleFieldScript.CONTEXT,
IpFieldScript.CONTEXT,
StringFieldScript.CONTEXT,
LongFieldScript.CONTEXT
);
}
};

View File

@ -49,8 +49,6 @@ import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.ScriptType;
import org.elasticsearch.search.MultiValueMode;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.RuntimeFields;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptBooleanFieldData;
@ -468,7 +466,7 @@ public class ScriptBooleanMappedFieldTypeTests extends AbstractNonTextScriptMapp
@Override
public Set<ScriptContext<?>> getSupportedContexts() {
return org.elasticsearch.common.collect.Set.of(DoubleScriptFieldScript.CONTEXT);
return org.elasticsearch.common.collect.Set.of(DoubleFieldScript.CONTEXT);
}
@Override
@ -483,15 +481,10 @@ public class ScriptBooleanMappedFieldTypeTests extends AbstractNonTextScriptMapp
return factory;
}
private BooleanScriptFieldScript.Factory factory(String code) {
private BooleanFieldScript.Factory factory(String code) {
switch (code) {
case "read_foo":
return (fieldName, params, lookup) -> (ctx) -> new BooleanScriptFieldScript(
fieldName,
params,
lookup,
ctx
) {
return (fieldName, params, lookup) -> (ctx) -> new BooleanFieldScript(fieldName, params, lookup, ctx) {
@Override
public void execute() {
for (Object foo : (List<?>) getSource().get("foo")) {
@ -500,12 +493,7 @@ public class ScriptBooleanMappedFieldTypeTests extends AbstractNonTextScriptMapp
}
};
case "xor_param":
return (fieldName, params, lookup) -> (ctx) -> new BooleanScriptFieldScript(
fieldName,
params,
lookup,
ctx
) {
return (fieldName, params, lookup) -> (ctx) -> new BooleanFieldScript(fieldName, params, lookup, ctx) {
@Override
public void execute() {
for (Object foo : (List<?>) getSource().get("foo")) {
@ -531,7 +519,7 @@ public class ScriptBooleanMappedFieldTypeTests extends AbstractNonTextScriptMapp
org.elasticsearch.common.collect.List.of(scriptPlugin, new RuntimeFields())
);
try (ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptModule.engines, scriptModule.contexts)) {
BooleanScriptFieldScript.Factory factory = scriptService.compile(script, BooleanScriptFieldScript.CONTEXT);
BooleanFieldScript.Factory factory = scriptService.compile(script, BooleanFieldScript.CONTEXT);
return new ScriptBooleanMappedFieldType("test", script, factory, emptyMap());
}
}

View File

@ -44,7 +44,6 @@ import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.ScriptType;
import org.elasticsearch.search.MultiValueMode;
import org.elasticsearch.xpack.runtimefields.DateScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.RuntimeFields;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptDateFieldData;
@ -497,7 +496,7 @@ public class ScriptDateMappedFieldTypeTests extends AbstractNonTextScriptMappedF
@Override
public Set<ScriptContext<?>> getSupportedContexts() {
return org.elasticsearch.common.collect.Set.of(DateScriptFieldScript.CONTEXT);
return org.elasticsearch.common.collect.Set.of(DateFieldScript.CONTEXT);
}
@Override
@ -512,10 +511,10 @@ public class ScriptDateMappedFieldTypeTests extends AbstractNonTextScriptMappedF
return factory;
}
private DateScriptFieldScript.Factory factory(String code) {
private DateFieldScript.Factory factory(String code) {
switch (code) {
case "read_timestamp":
return (fieldName, params, lookup, formatter) -> ctx -> new DateScriptFieldScript(
return (fieldName, params, lookup, formatter) -> ctx -> new DateFieldScript(
fieldName,
params,
lookup,
@ -525,13 +524,13 @@ public class ScriptDateMappedFieldTypeTests extends AbstractNonTextScriptMappedF
@Override
public void execute() {
for (Object timestamp : (List<?>) getSource().get("timestamp")) {
DateScriptFieldScript.Parse parse = new DateScriptFieldScript.Parse(this);
DateFieldScript.Parse parse = new DateFieldScript.Parse(this);
emit(parse.parse(timestamp));
}
}
};
case "add_days":
return (fieldName, params, lookup, formatter) -> ctx -> new DateScriptFieldScript(
return (fieldName, params, lookup, formatter) -> ctx -> new DateFieldScript(
fieldName,
params,
lookup,
@ -566,7 +565,7 @@ public class ScriptDateMappedFieldTypeTests extends AbstractNonTextScriptMappedF
org.elasticsearch.common.collect.List.of(scriptPlugin, new RuntimeFields())
);
try (ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptModule.engines, scriptModule.contexts)) {
DateScriptFieldScript.Factory factory = scriptService.compile(script, DateScriptFieldScript.CONTEXT);
DateFieldScript.Factory factory = scriptService.compile(script, DateFieldScript.CONTEXT);
return new ScriptDateMappedFieldType("test", script, factory, dateTimeFormatter, emptyMap());
}
}

View File

@ -38,7 +38,6 @@ import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.ScriptType;
import org.elasticsearch.search.MultiValueMode;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.RuntimeFields;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptDoubleFieldData;
@ -276,7 +275,7 @@ public class ScriptDoubleMappedFieldTypeTests extends AbstractNonTextScriptMappe
@Override
public Set<ScriptContext<?>> getSupportedContexts() {
return org.elasticsearch.common.collect.Set.of(DoubleScriptFieldScript.CONTEXT);
return org.elasticsearch.common.collect.Set.of(DoubleFieldScript.CONTEXT);
}
@Override
@ -291,10 +290,10 @@ public class ScriptDoubleMappedFieldTypeTests extends AbstractNonTextScriptMappe
return factory;
}
private DoubleScriptFieldScript.Factory factory(String code) {
private DoubleFieldScript.Factory factory(String code) {
switch (code) {
case "read_foo":
return (fieldName, params, lookup) -> (ctx) -> new DoubleScriptFieldScript(fieldName, params, lookup, ctx) {
return (fieldName, params, lookup) -> (ctx) -> new DoubleFieldScript(fieldName, params, lookup, ctx) {
@Override
public void execute() {
for (Object foo : (List<?>) getSource().get("foo")) {
@ -303,7 +302,7 @@ public class ScriptDoubleMappedFieldTypeTests extends AbstractNonTextScriptMappe
}
};
case "add_param":
return (fieldName, params, lookup) -> (ctx) -> new DoubleScriptFieldScript(fieldName, params, lookup, ctx) {
return (fieldName, params, lookup) -> (ctx) -> new DoubleFieldScript(fieldName, params, lookup, ctx) {
@Override
public void execute() {
for (Object foo : (List<?>) getSource().get("foo")) {
@ -329,7 +328,7 @@ public class ScriptDoubleMappedFieldTypeTests extends AbstractNonTextScriptMappe
org.elasticsearch.common.collect.List.of(scriptPlugin, new RuntimeFields())
);
try (ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptModule.engines, scriptModule.contexts)) {
DoubleScriptFieldScript.Factory factory = scriptService.compile(script, DoubleScriptFieldScript.CONTEXT);
DoubleFieldScript.Factory factory = scriptService.compile(script, DoubleFieldScript.CONTEXT);
return new ScriptDoubleMappedFieldType("test", script, factory, emptyMap());
}
}

View File

@ -38,9 +38,7 @@ import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.ScriptType;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.MultiValueMode;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.RuntimeFields;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptBinaryFieldData;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptIpFieldData;
@ -320,7 +318,7 @@ public class ScriptIpMappedFieldTypeTests extends AbstractScriptMappedFieldTypeT
@Override
public Set<ScriptContext<?>> getSupportedContexts() {
return org.elasticsearch.common.collect.Set.of(StringScriptFieldScript.CONTEXT);
return org.elasticsearch.common.collect.Set.of(StringFieldScript.CONTEXT);
}
@Override
@ -335,10 +333,10 @@ public class ScriptIpMappedFieldTypeTests extends AbstractScriptMappedFieldTypeT
return factory;
}
private IpScriptFieldScript.Factory factory(String code) {
private IpFieldScript.Factory factory(String code) {
switch (code) {
case "read_foo":
return (fieldName, params, lookup) -> (ctx) -> new IpScriptFieldScript(fieldName, params, lookup, ctx) {
return (fieldName, params, lookup) -> (ctx) -> new IpFieldScript(fieldName, params, lookup, ctx) {
@Override
public void execute() {
for (Object foo : (List<?>) getSource().get("foo")) {
@ -347,7 +345,7 @@ public class ScriptIpMappedFieldTypeTests extends AbstractScriptMappedFieldTypeT
}
};
case "append_param":
return (fieldName, params, lookup) -> (ctx) -> new IpScriptFieldScript(fieldName, params, lookup, ctx) {
return (fieldName, params, lookup) -> (ctx) -> new IpFieldScript(fieldName, params, lookup, ctx) {
@Override
public void execute() {
for (Object foo : (List<?>) getSource().get("foo")) {
@ -373,7 +371,7 @@ public class ScriptIpMappedFieldTypeTests extends AbstractScriptMappedFieldTypeT
org.elasticsearch.common.collect.List.of(scriptPlugin, new RuntimeFields())
);
try (ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptModule.engines, scriptModule.contexts)) {
IpScriptFieldScript.Factory factory = scriptService.compile(script, IpScriptFieldScript.CONTEXT);
IpFieldScript.Factory factory = scriptService.compile(script, IpFieldScript.CONTEXT);
return new ScriptIpMappedFieldType("test", script, factory, emptyMap());
}
}

View File

@ -42,7 +42,6 @@ import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.ScriptType;
import org.elasticsearch.search.MultiValueMode;
import org.elasticsearch.xpack.runtimefields.RuntimeFields;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptBinaryFieldData;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptStringFieldData;
@ -384,7 +383,7 @@ public class ScriptKeywordMappedFieldTypeTests extends AbstractScriptMappedField
@Override
public Set<ScriptContext<?>> getSupportedContexts() {
return org.elasticsearch.common.collect.Set.of(StringScriptFieldScript.CONTEXT);
return org.elasticsearch.common.collect.Set.of(StringFieldScript.CONTEXT);
}
@Override
@ -399,10 +398,10 @@ public class ScriptKeywordMappedFieldTypeTests extends AbstractScriptMappedField
return factory;
}
private StringScriptFieldScript.Factory factory(String code) {
private StringFieldScript.Factory factory(String code) {
switch (code) {
case "read_foo":
return (fieldName, params, lookup) -> ctx -> new StringScriptFieldScript(fieldName, params, lookup, ctx) {
return (fieldName, params, lookup) -> ctx -> new StringFieldScript(fieldName, params, lookup, ctx) {
@Override
public void execute() {
for (Object foo : (List<?>) getSource().get("foo")) {
@ -411,7 +410,7 @@ public class ScriptKeywordMappedFieldTypeTests extends AbstractScriptMappedField
}
};
case "append_param":
return (fieldName, params, lookup) -> ctx -> new StringScriptFieldScript(fieldName, params, lookup, ctx) {
return (fieldName, params, lookup) -> ctx -> new StringFieldScript(fieldName, params, lookup, ctx) {
@Override
public void execute() {
for (Object foo : (List<?>) getSource().get("foo")) {
@ -437,7 +436,7 @@ public class ScriptKeywordMappedFieldTypeTests extends AbstractScriptMappedField
org.elasticsearch.common.collect.List.of(scriptPlugin, new RuntimeFields())
);
try (ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptModule.engines, scriptModule.contexts)) {
StringScriptFieldScript.Factory factory = scriptService.compile(script, StringScriptFieldScript.CONTEXT);
StringFieldScript.Factory factory = scriptService.compile(script, StringFieldScript.CONTEXT);
return new ScriptKeywordMappedFieldType("test", script, factory, emptyMap());
}
}

View File

@ -39,7 +39,6 @@ import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.ScriptType;
import org.elasticsearch.search.MultiValueMode;
import org.elasticsearch.xpack.runtimefields.LongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.RuntimeFields;
import org.elasticsearch.xpack.runtimefields.fielddata.ScriptLongFieldData;
@ -303,7 +302,7 @@ public class ScriptLongMappedFieldTypeTests extends AbstractNonTextScriptMappedF
@Override
public Set<ScriptContext<?>> getSupportedContexts() {
return org.elasticsearch.common.collect.Set.of(LongScriptFieldScript.CONTEXT);
return org.elasticsearch.common.collect.Set.of(LongFieldScript.CONTEXT);
}
@Override
@ -318,10 +317,10 @@ public class ScriptLongMappedFieldTypeTests extends AbstractNonTextScriptMappedF
return factory;
}
private LongScriptFieldScript.Factory factory(String code) {
private LongFieldScript.Factory factory(String code) {
switch (code) {
case "read_foo":
return (fieldName, params, lookup) -> (ctx) -> new LongScriptFieldScript(fieldName, params, lookup, ctx) {
return (fieldName, params, lookup) -> (ctx) -> new LongFieldScript(fieldName, params, lookup, ctx) {
@Override
public void execute() {
for (Object foo : (List<?>) getSource().get("foo")) {
@ -330,7 +329,7 @@ public class ScriptLongMappedFieldTypeTests extends AbstractNonTextScriptMappedF
}
};
case "add_param":
return (fieldName, params, lookup) -> (ctx) -> new LongScriptFieldScript(fieldName, params, lookup, ctx) {
return (fieldName, params, lookup) -> (ctx) -> new LongFieldScript(fieldName, params, lookup, ctx) {
@Override
public void execute() {
for (Object foo : (List<?>) getSource().get("foo")) {
@ -341,7 +340,7 @@ public class ScriptLongMappedFieldTypeTests extends AbstractNonTextScriptMappedF
case "millis_ago":
// Painless actually call System.currentTimeMillis. We could mock the time but this works fine too.
long now = System.currentTimeMillis();
return (fieldName, params, lookup) -> (ctx) -> new LongScriptFieldScript(fieldName, params, lookup, ctx) {
return (fieldName, params, lookup) -> (ctx) -> new LongFieldScript(fieldName, params, lookup, ctx) {
@Override
public void execute() {
for (Object timestamp : (List<?>) getSource().get("timestamp")) {
@ -367,7 +366,7 @@ public class ScriptLongMappedFieldTypeTests extends AbstractNonTextScriptMappedF
org.elasticsearch.common.collect.List.of(scriptPlugin, new RuntimeFields())
);
try (ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptModule.engines, scriptModule.contexts)) {
LongScriptFieldScript.Factory factory = scriptService.compile(script, LongScriptFieldScript.CONTEXT);
LongFieldScript.Factory factory = scriptService.compile(script, LongFieldScript.CONTEXT);
return new ScriptLongMappedFieldType("test", script, factory, emptyMap());
}
}

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.DirectoryReader;
@ -20,8 +20,8 @@ import java.io.IOException;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.mock;
public class StringScriptFieldScriptTests extends ScriptFieldScriptTestCase<StringScriptFieldScript.Factory> {
public static final StringScriptFieldScript.Factory DUMMY = (fieldName, params, lookup) -> ctx -> new StringScriptFieldScript(
public class StringFieldScriptTests extends FieldScriptTestCase<StringFieldScript.Factory> {
public static final StringFieldScript.Factory DUMMY = (fieldName, params, lookup) -> ctx -> new StringFieldScript(
fieldName,
params,
lookup,
@ -34,12 +34,12 @@ public class StringScriptFieldScriptTests extends ScriptFieldScriptTestCase<Stri
};
@Override
protected ScriptContext<StringScriptFieldScript.Factory> context() {
return StringScriptFieldScript.CONTEXT;
protected ScriptContext<StringFieldScript.Factory> context() {
return StringFieldScript.CONTEXT;
}
@Override
protected StringScriptFieldScript.Factory dummyScript() {
protected StringFieldScript.Factory dummyScript() {
return DUMMY;
}
@ -47,7 +47,7 @@ public class StringScriptFieldScriptTests extends ScriptFieldScriptTestCase<Stri
try (Directory directory = newDirectory(); RandomIndexWriter iw = new RandomIndexWriter(random(), directory)) {
iw.addDocument(org.elasticsearch.common.collect.List.of(new StoredField("_source", new BytesRef("{}"))));
try (DirectoryReader reader = iw.getReader()) {
StringScriptFieldScript script = new StringScriptFieldScript(
StringFieldScript script = new StringFieldScript(
"test",
org.elasticsearch.common.collect.Map.of(),
new SearchLookup(mock(MapperService.class), (ft, lookup) -> null, null),
@ -55,7 +55,7 @@ public class StringScriptFieldScriptTests extends ScriptFieldScriptTestCase<Stri
) {
@Override
public void execute() {
for (int i = 0; i <= AbstractScriptFieldScript.MAX_VALUES; i++) {
for (int i = 0; i <= AbstractFieldScript.MAX_VALUES; i++) {
emit("test");
}
}
@ -73,7 +73,7 @@ public class StringScriptFieldScriptTests extends ScriptFieldScriptTestCase<Stri
try (Directory directory = newDirectory(); RandomIndexWriter iw = new RandomIndexWriter(random(), directory)) {
iw.addDocument(org.elasticsearch.common.collect.List.of(new StoredField("_source", new BytesRef("{}"))));
try (DirectoryReader reader = iw.getReader()) {
StringScriptFieldScript script = new StringScriptFieldScript(
StringFieldScript script = new StringFieldScript(
"test",
org.elasticsearch.common.collect.Map.of(),
new SearchLookup(mock(MapperService.class), (ft, lookup) -> null, null),
@ -82,7 +82,7 @@ public class StringScriptFieldScriptTests extends ScriptFieldScriptTestCase<Stri
@Override
public void execute() {
StringBuilder big = new StringBuilder();
while (big.length() < StringScriptFieldScript.MAX_CHARS / 4) {
while (big.length() < StringFieldScript.MAX_CHARS / 4) {
big.append("test");
}
String bigString = big.toString();

View File

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.runtimefields;
package org.elasticsearch.xpack.runtimefields.mapper;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.script.ScriptContext;

View File

@ -10,7 +10,7 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.util.automaton.ByteRunAutomaton;
import org.elasticsearch.xpack.runtimefields.BooleanScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.BooleanFieldScript;
import java.util.ArrayList;
import java.util.List;
@ -22,7 +22,7 @@ import static org.mockito.Mockito.mock;
public abstract class AbstractBooleanScriptFieldQueryTestCase<T extends AbstractBooleanScriptFieldQuery> extends
AbstractScriptFieldQueryTestCase<T> {
protected final BooleanScriptFieldScript.LeafFactory leafFactory = mock(BooleanScriptFieldScript.LeafFactory.class);
protected final BooleanFieldScript.LeafFactory leafFactory = mock(BooleanFieldScript.LeafFactory.class);
@Override
public final void testVisit() {

View File

@ -6,14 +6,14 @@
package org.elasticsearch.xpack.runtimefields.query;
import org.elasticsearch.xpack.runtimefields.DoubleScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DoubleFieldScript;
import static org.mockito.Mockito.mock;
public abstract class AbstractDoubleScriptFieldQueryTestCase<T extends AbstractDoubleScriptFieldQuery> extends
AbstractScriptFieldQueryTestCase<T> {
protected final DoubleScriptFieldScript.LeafFactory leafFactory = mock(DoubleScriptFieldScript.LeafFactory.class);
protected final DoubleFieldScript.LeafFactory leafFactory = mock(DoubleFieldScript.LeafFactory.class);
@Override
public final void testVisit() {

View File

@ -8,7 +8,7 @@ package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.document.InetAddressPoint;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.xpack.runtimefields.IpScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.IpFieldScript;
import java.net.InetAddress;
@ -16,7 +16,7 @@ import static org.mockito.Mockito.mock;
public abstract class AbstractIpScriptFieldQueryTestCase<T extends AbstractIpScriptFieldQuery> extends AbstractScriptFieldQueryTestCase<T> {
protected final IpScriptFieldScript.LeafFactory leafFactory = mock(IpScriptFieldScript.LeafFactory.class);
protected final IpFieldScript.LeafFactory leafFactory = mock(IpFieldScript.LeafFactory.class);
@Override
public final void testVisit() {

View File

@ -7,13 +7,13 @@
package org.elasticsearch.xpack.runtimefields.query;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.xpack.runtimefields.AbstractLongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.AbstractLongFieldScript;
import java.util.function.Function;
public abstract class AbstractLongScriptFieldQueryTestCase<T extends AbstractLongScriptFieldQuery> extends AbstractScriptFieldQueryTestCase<
T> {
protected final Function<LeafReaderContext, AbstractLongScriptFieldScript> leafFactory = ctx -> null;
protected final Function<LeafReaderContext, AbstractLongFieldScript> leafFactory = ctx -> null;
@Override
public final void testVisit() {

View File

@ -10,7 +10,7 @@ import org.apache.lucene.index.Term;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.util.automaton.ByteRunAutomaton;
import org.elasticsearch.xpack.runtimefields.StringScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.StringFieldScript;
import java.util.ArrayList;
import java.util.List;
@ -23,7 +23,7 @@ import static org.mockito.Mockito.mock;
public abstract class AbstractStringScriptFieldQueryTestCase<T extends AbstractStringScriptFieldQuery> extends
AbstractScriptFieldQueryTestCase<T> {
protected final StringScriptFieldScript.LeafFactory leafFactory = mock(StringScriptFieldScript.LeafFactory.class);
protected final StringFieldScript.LeafFactory leafFactory = mock(StringFieldScript.LeafFactory.class);
/**
* {@link Query#visit Visit} a query, collecting {@link ByteRunAutomaton automata},

View File

@ -8,7 +8,6 @@ package org.elasticsearch.xpack.runtimefields.query;
import com.carrotsearch.hppc.LongHashSet;
import com.carrotsearch.hppc.LongSet;
import org.elasticsearch.script.Script;
import java.util.Arrays;

View File

@ -18,8 +18,8 @@ import org.apache.lucene.util.BytesRef;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.runtimefields.AbstractLongScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.DateScriptFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.AbstractLongFieldScript;
import org.elasticsearch.xpack.runtimefields.mapper.DateFieldScript;
import java.io.IOException;
import java.util.Collections;
@ -29,7 +29,7 @@ import java.util.function.Function;
import static org.hamcrest.Matchers.equalTo;
public class LongScriptFieldDistanceFeatureQueryTests extends AbstractScriptFieldQueryTestCase<LongScriptFieldDistanceFeatureQuery> {
private final Function<LeafReaderContext, AbstractLongScriptFieldScript> leafFactory = ctx -> null;
private final Function<LeafReaderContext, AbstractLongFieldScript> leafFactory = ctx -> null;
@Override
protected LongScriptFieldDistanceFeatureQuery createTestInstance() {
@ -90,7 +90,7 @@ public class LongScriptFieldDistanceFeatureQueryTests extends AbstractScriptFiel
);
try (DirectoryReader reader = iw.getReader()) {
IndexSearcher searcher = newSearcher(reader);
Function<LeafReaderContext, AbstractLongScriptFieldScript> leafFactory = ctx -> new DateScriptFieldScript(
Function<LeafReaderContext, AbstractLongFieldScript> leafFactory = ctx -> new DateFieldScript(
"test",
Collections.emptyMap(),
new SearchLookup(null, null, null),