Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NumberFieldMapper Referencing its Own Builder #77131

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static class Builder extends FieldMapper.Builder {

private final Parameter<Number> nullValue;

private final Parameter<Script> script = Parameter.scriptParam(m -> toType(m).builder.script.get());
private final Parameter<Script> script = Parameter.scriptParam(m -> toType(m).script);
private final Parameter<String> onScriptError = Parameter.onScriptErrorParam(m -> toType(m).onScriptError, script);
private final Parameter<Boolean> dimension;

Expand Down Expand Up @@ -1084,7 +1084,6 @@ public boolean isDimension() {
}
}

private final Builder builder;
private final NumberType type;

private final boolean indexed;
Expand All @@ -1097,6 +1096,8 @@ public boolean isDimension() {
private final boolean ignoreMalformedByDefault;
private final boolean coerceByDefault;
private final boolean dimension;
private final ScriptCompiler scriptCompiler;
private final Script script;

private NumberFieldMapper(
String simpleName,
Expand All @@ -1116,7 +1117,8 @@ private NumberFieldMapper(
this.coerceByDefault = builder.coerce.getDefaultValue().value();
this.scriptValues = builder.scriptValues();
this.dimension = builder.dimension.getValue();
this.builder = builder;
this.scriptCompiler = builder.scriptCompiler;
this.script = builder.script.getValue();
}

boolean coerce() {
Expand Down Expand Up @@ -1203,7 +1205,7 @@ protected void indexScriptValues(SearchLookup searchLookup, LeafReaderContext re

@Override
public FieldMapper.Builder getMergeBuilder() {
return new Builder(simpleName(), type, builder.scriptCompiler, ignoreMalformedByDefault, coerceByDefault)
return new Builder(simpleName(), type, scriptCompiler, ignoreMalformedByDefault, coerceByDefault)
.dimension(dimension).init(this);
}
}