Skip to content
Merged
Show file tree
Hide file tree
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,6 +81,9 @@ public class RuntimeField implements DynamicTemplateVariant, JsonpSerializable {
@Nullable
private final Script script;

@Nullable
private final OnScriptError onScriptError;

private final RuntimeFieldType type;

// ---------------------------------------------------------------------------------------------
Expand All @@ -94,6 +97,7 @@ private RuntimeField(Builder builder) {
this.targetField = builder.targetField;
this.targetIndex = builder.targetIndex;
this.script = builder.script;
this.onScriptError = builder.onScriptError;
this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type");

}
Expand Down Expand Up @@ -178,6 +182,14 @@ public final Script script() {
return this.script;
}

/**
* API name: {@code on_script_error}
*/
@Nullable
public final OnScriptError onScriptError() {
return this.onScriptError;
}

/**
* Required - Field type, which can be: <code>boolean</code>,
* <code>composite</code>, <code>date</code>, <code>double</code>,
Expand Down Expand Up @@ -247,6 +259,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
this.script.serialize(generator, mapper);

}
if (this.onScriptError != null) {
generator.writeKey("on_script_error");
this.onScriptError.serialize(generator, mapper);
}
generator.writeKey("type");
this.type.serialize(generator, mapper);

Expand Down Expand Up @@ -285,6 +301,9 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder> implement
@Nullable
private Script script;

@Nullable
private OnScriptError onScriptError;

private RuntimeFieldType type;

public Builder() {
Expand All @@ -297,6 +316,7 @@ private Builder(RuntimeField instance) {
this.targetField = instance.targetField;
this.targetIndex = instance.targetIndex;
this.script = instance.script;
this.onScriptError = instance.onScriptError;
this.type = instance.type;

}
Expand Down Expand Up @@ -431,6 +451,14 @@ public final Builder script(Function<Script.Builder, ObjectBuilder<Script>> fn)
return this.script(fn.apply(new Script.Builder()).build());
}

/**
* API name: {@code on_script_error}
*/
public final Builder onScriptError(@Nullable OnScriptError value) {
this.onScriptError = value;
return this;
}

/**
* Required - Field type, which can be: <code>boolean</code>,
* <code>composite</code>, <code>date</code>, <code>double</code>,
Expand Down Expand Up @@ -486,6 +514,7 @@ protected static void setupRuntimeFieldDeserializer(ObjectDeserializer<RuntimeFi
op.add(Builder::targetField, JsonpDeserializer.stringDeserializer(), "target_field");
op.add(Builder::targetIndex, JsonpDeserializer.stringDeserializer(), "target_index");
op.add(Builder::script, Script._DESERIALIZER, "script");
op.add(Builder::onScriptError, OnScriptError._DESERIALIZER, "on_script_error");
op.add(Builder::type, RuntimeFieldType._DESERIALIZER, "type");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@
// typedef: _global.bulk.OperationContainer

/**
*
* An action line, which is the first line of each operation in a bulk request.
* It specifies the action to perform (<code>index</code>, <code>create</code>,
* <code>update</code>, or <code>delete</code>) and its metadata, such as the
* target index and document ID. All actions except <code>delete</code> expect a
* source line to follow.
*
* @see <a href=
* "../../doc-files/api-spec.html#_global.bulk.OperationContainer">API
* specification</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
// typedef: _global.bulk.UpdateAction

/**
*
* The source line that must follow an <code>update</code> action line. It
* specifies the partial document, script, or upsert options to apply, plus
* optional update settings.
*
* @see <a href="../../doc-files/api-spec.html#_global.bulk.UpdateAction">API
* specification</a>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,23 +186,23 @@ public SourceConfig build() {
public static final JsonpDeserializer<SourceConfig> _DESERIALIZER = JsonpDeserializer
.lazy(() -> JsonpDeserializer.of(EnumSet.of(JsonParser.Event.START_OBJECT, JsonParser.Event.START_ARRAY,
JsonParser.Event.VALUE_TRUE, JsonParser.Event.VALUE_FALSE), (parser, mapper, event) -> {
switch (event) {
case VALUE_TRUE :
return SourceConfig.of(b -> b.fetch(true));
case VALUE_FALSE :
return SourceConfig.of(b -> b.fetch(false));
case START_ARRAY : {
List<String> includes = JsonpDeserializer
.arrayDeserializer(JsonpDeserializer.stringDeserializer())
.deserialize(parser, mapper, event);
return SourceConfig.of(b -> b.filter(f -> f.includes(includes)));
}
case START_OBJECT : {
SourceFilter filter = SourceFilter._DESERIALIZER.deserialize(parser, mapper, event);
return SourceConfig.of(b -> b.filter(filter));
}
default :
return null;
}
}));
switch (event) {
case VALUE_TRUE :
return SourceConfig.of(b -> b.fetch(true));
case VALUE_FALSE :
return SourceConfig.of(b -> b.fetch(false));
case START_ARRAY : {
List<String> includes = JsonpDeserializer
.arrayDeserializer(JsonpDeserializer.stringDeserializer())
.deserialize(parser, mapper, event);
return SourceConfig.of(b -> b.filter(f -> f.includes(includes)));
}
case START_OBJECT : {
SourceFilter filter = SourceFilter._DESERIALIZER.deserialize(parser, mapper, event);
return SourceConfig.of(b -> b.filter(filter));
}
default :
return null;
}
}));
}
Loading
Loading