Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Add document lifecycle guide and runnable sample ([#2017](https://github.com/opensearch-project/opensearch-java/pull/2017))

### Fixed
- Fix `PathHierarchyTokenizer` optional fields incorrectly marked required causing deserialization failure ([#2038](https://github.com/opensearch-project/opensearch-java/pull/2038))

## [Unreleased 3.x]
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ public class DerivedField implements PlainJsonSerializable, ToCopyableBuilder<De
@Nullable
private final Boolean ignoreMalformed;

@Nonnull
private final String name;

@Nullable
private final String prefilterField;

Expand All @@ -88,7 +85,6 @@ public class DerivedField implements PlainJsonSerializable, ToCopyableBuilder<De
private DerivedField(Builder builder) {
this.format = builder.format;
this.ignoreMalformed = builder.ignoreMalformed;
this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name");
this.prefilterField = builder.prefilterField;
this.properties = ApiTypeHelper.unmodifiable(builder.properties);
this.script = ApiTypeHelper.requireNonNull(builder.script, this, "script");
Expand All @@ -115,14 +111,6 @@ public final Boolean ignoreMalformed() {
return this.ignoreMalformed;
}

/**
* Required - API name: {@code name}
*/
@Nonnull
public final String name() {
return this.name;
}

/**
* API name: {@code prefilter_field}
*/
Expand Down Expand Up @@ -176,9 +164,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.write(this.ignoreMalformed);
}

generator.writeKey("name");
generator.write(this.name);

if (this.prefilterField != null) {
generator.writeKey("prefilter_field");
generator.write(this.prefilterField);
Expand Down Expand Up @@ -222,7 +207,6 @@ public static class Builder extends ObjectBuilderBase implements CopyableBuilder
private String format;
@Nullable
private Boolean ignoreMalformed;
private String name;
@Nullable
private String prefilterField;
@Nullable
Expand All @@ -235,7 +219,6 @@ public Builder() {}
private Builder(DerivedField o) {
this.format = o.format;
this.ignoreMalformed = o.ignoreMalformed;
this.name = o.name;
this.prefilterField = o.prefilterField;
this.properties = _mapCopy(o.properties);
this.script = o.script;
Expand All @@ -245,7 +228,6 @@ private Builder(DerivedField o) {
private Builder(Builder o) {
this.format = o.format;
this.ignoreMalformed = o.ignoreMalformed;
this.name = o.name;
this.prefilterField = o.prefilterField;
this.properties = _mapCopy(o.properties);
this.script = o.script;
Expand Down Expand Up @@ -276,15 +258,6 @@ public final Builder ignoreMalformed(@Nullable Boolean value) {
return this;
}

/**
* Required - API name: {@code name}
*/
@Nonnull
public final Builder name(String value) {
this.name = value;
return this;
}

/**
* API name: {@code prefilter_field}
*/
Expand Down Expand Up @@ -373,7 +346,6 @@ public DerivedField build() {
protected static void setupDerivedFieldDeserializer(ObjectDeserializer<DerivedField.Builder> op) {
op.add(Builder::format, JsonpDeserializer.stringDeserializer(), "format");
op.add(Builder::ignoreMalformed, JsonpDeserializer.booleanDeserializer(), "ignore_malformed");
op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name");
op.add(Builder::prefilterField, JsonpDeserializer.stringDeserializer(), "prefilter_field");
op.add(Builder::properties, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "properties");
op.add(Builder::script, Script._DESERIALIZER, "script");
Expand All @@ -385,7 +357,6 @@ public int hashCode() {
int result = 17;
result = 31 * result + Objects.hashCode(this.format);
result = 31 * result + Objects.hashCode(this.ignoreMalformed);
result = 31 * result + this.name.hashCode();
result = 31 * result + Objects.hashCode(this.prefilterField);
result = 31 * result + Objects.hashCode(this.properties);
result = 31 * result + this.script.hashCode();
Expand All @@ -400,7 +371,6 @@ public boolean equals(Object o) {
DerivedField other = (DerivedField) o;
return Objects.equals(this.format, other.format)
&& Objects.equals(this.ignoreMalformed, other.ignoreMalformed)
&& this.name.equals(other.name)
&& Objects.equals(this.prefilterField, other.prefilterField)
&& Objects.equals(this.properties, other.properties)
&& this.script.equals(other.script)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public class ShardFailure implements PlainJsonSerializable, ToCopyableBuilder<Sh
@Nonnull
private final ErrorCause reason;

private final int shard;
@Nullable
private final Integer shard;

@Nullable
private final String status;
Expand All @@ -83,7 +84,7 @@ private ShardFailure(Builder builder) {
this.node = builder.node;
this.primary = ApiTypeHelper.requireNonNull(builder.primary, this, "primary");
this.reason = ApiTypeHelper.requireNonNull(builder.reason, this, "reason");
this.shard = ApiTypeHelper.requireNonNull(builder.shard, this, "shard");
this.shard = builder.shard;
this.status = builder.status;
}

Expand Down Expand Up @@ -123,9 +124,10 @@ public final ErrorCause reason() {
}

/**
* Required - API name: {@code shard}
* API name: {@code shard}
*/
public final int shard() {
@Nullable
public final Integer shard() {
return this.shard;
}

Expand Down Expand Up @@ -164,8 +166,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("reason");
this.reason.serialize(generator, mapper);

generator.writeKey("shard");
generator.write(this.shard);
if (this.shard != null) {
generator.writeKey("shard");
generator.write(this.shard);
}

if (this.status != null) {
generator.writeKey("status");
Expand Down Expand Up @@ -271,7 +275,7 @@ public final Builder reason(Function<ErrorCause.Builder, ObjectBuilder<ErrorCaus
}

/**
* Required - API name: {@code shard}
* API name: {@code shard}
*/
@Nonnull
public final Builder shard(int value) {
Expand Down Expand Up @@ -328,7 +332,7 @@ public int hashCode() {
result = 31 * result + Objects.hashCode(this.node);
result = 31 * result + Boolean.hashCode(this.primary);
result = 31 * result + this.reason.hashCode();
result = 31 * result + Integer.hashCode(this.shard);
result = 31 * result + Objects.hashCode(this.shard);
result = 31 * result + Objects.hashCode(this.status);
return result;
}
Expand All @@ -342,7 +346,7 @@ public boolean equals(Object o) {
&& Objects.equals(this.node, other.node)
&& this.primary == other.primary
&& this.reason.equals(other.reason)
&& this.shard == other.shard
&& Objects.equals(this.shard, other.shard)
&& Objects.equals(this.status, other.status);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,30 @@ public class PathHierarchyTokenizer extends TokenizerBase
TokenizerDefinitionVariant,
ToCopyableBuilder<PathHierarchyTokenizer.Builder, PathHierarchyTokenizer> {

private final int bufferSize;
@Nullable
private final Integer bufferSize;

@Nonnull
@Nullable
private final String delimiter;

@Nullable
private final String replacement;

private final boolean reverse;
@Nullable
private final Boolean reverse;

private final int skip;
@Nullable
private final Integer skip;

// ---------------------------------------------------------------------------------------------

private PathHierarchyTokenizer(Builder builder) {
super(builder);
this.bufferSize = ApiTypeHelper.requireNonNull(builder.bufferSize, this, "bufferSize");
this.delimiter = ApiTypeHelper.requireNonNull(builder.delimiter, this, "delimiter");
this.bufferSize = builder.bufferSize;
this.delimiter = builder.delimiter;
this.replacement = builder.replacement;
this.reverse = ApiTypeHelper.requireNonNull(builder.reverse, this, "reverse");
this.skip = ApiTypeHelper.requireNonNull(builder.skip, this, "skip");
this.reverse = builder.reverse;
this.skip = builder.skip;
}

public static PathHierarchyTokenizer of(Function<PathHierarchyTokenizer.Builder, ObjectBuilder<PathHierarchyTokenizer>> fn) {
Expand All @@ -97,16 +100,17 @@ public TokenizerDefinition.Kind _tokenizerDefinitionKind() {
}

/**
* Required - API name: {@code buffer_size}
* API name: {@code buffer_size}
*/
public final int bufferSize() {
@Nullable
public final Integer bufferSize() {
return this.bufferSize;
}

/**
* Required - API name: {@code delimiter}
* API name: {@code delimiter}
*/
@Nonnull
@Nullable
public final String delimiter() {
return this.delimiter;
}
Expand All @@ -120,38 +124,48 @@ public final String replacement() {
}

/**
* Required - API name: {@code reverse}
* API name: {@code reverse}
*/
public final boolean reverse() {
@Nullable
public final Boolean reverse() {
return this.reverse;
}

/**
* Required - API name: {@code skip}
* API name: {@code skip}
*/
public final int skip() {
@Nullable
public final Integer skip() {
return this.skip;
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.write("type", "path_hierarchy");
super.serializeInternal(generator, mapper);
generator.writeKey("buffer_size");
generator.write(this.bufferSize);
if (this.bufferSize != null) {
generator.writeKey("buffer_size");
generator.write(this.bufferSize);
}

generator.writeKey("delimiter");
generator.write(this.delimiter);
if (this.delimiter != null) {
generator.writeKey("delimiter");
generator.write(this.delimiter);
}

if (this.replacement != null) {
generator.writeKey("replacement");
generator.write(this.replacement);
}

generator.writeKey("reverse");
generator.write(this.reverse);
if (this.reverse != null) {
generator.writeKey("reverse");
generator.write(this.reverse);
}

generator.writeKey("skip");
generator.write(this.skip);
if (this.skip != null) {
generator.writeKey("skip");
generator.write(this.skip);
}
}

// ---------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -211,7 +225,7 @@ protected Builder self() {
}

/**
* Required - API name: {@code buffer_size}
* API name: {@code buffer_size}
*/
@Nonnull
public final Builder bufferSize(int value) {
Expand All @@ -220,7 +234,7 @@ public final Builder bufferSize(int value) {
}

/**
* Required - API name: {@code delimiter}
* API name: {@code delimiter}
*/
@Nonnull
public final Builder delimiter(String value) {
Expand All @@ -238,7 +252,7 @@ public final Builder replacement(@Nullable String value) {
}

/**
* Required - API name: {@code reverse}
* API name: {@code reverse}
*/
@Nonnull
public final Builder reverse(boolean value) {
Expand All @@ -247,7 +261,7 @@ public final Builder reverse(boolean value) {
}

/**
* Required - API name: {@code skip}
* API name: {@code skip}
*/
@Nonnull
public final Builder skip(int value) {
Expand Down Expand Up @@ -293,11 +307,11 @@ protected static void setupPathHierarchyTokenizerDeserializer(ObjectDeserializer
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + Integer.hashCode(this.bufferSize);
result = 31 * result + this.delimiter.hashCode();
result = 31 * result + Objects.hashCode(this.bufferSize);
result = 31 * result + Objects.hashCode(this.delimiter);
result = 31 * result + Objects.hashCode(this.replacement);
result = 31 * result + Boolean.hashCode(this.reverse);
result = 31 * result + Integer.hashCode(this.skip);
result = 31 * result + Objects.hashCode(this.reverse);
result = 31 * result + Objects.hashCode(this.skip);
return result;
}

Expand All @@ -309,10 +323,10 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
PathHierarchyTokenizer other = (PathHierarchyTokenizer) o;
return this.bufferSize == other.bufferSize
&& this.delimiter.equals(other.delimiter)
return Objects.equals(this.bufferSize, other.bufferSize)
&& Objects.equals(this.delimiter, other.delimiter)
&& Objects.equals(this.replacement, other.replacement)
&& this.reverse == other.reverse
&& this.skip == other.skip;
&& Objects.equals(this.reverse, other.reverse)
&& Objects.equals(this.skip, other.skip);
}
}
Loading
Loading