|
72 | 72 | public class Hit<TDocument> implements JsonpSerializable {
|
73 | 73 | private final String index;
|
74 | 74 |
|
| 75 | + @Nullable |
75 | 76 | private final String id;
|
76 | 77 |
|
77 | 78 | @Nullable
|
@@ -126,7 +127,7 @@ public class Hit<TDocument> implements JsonpSerializable {
|
126 | 127 | private Hit(Builder<TDocument> builder) {
|
127 | 128 |
|
128 | 129 | this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index");
|
129 |
| - this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); |
| 130 | + this.id = builder.id; |
130 | 131 | this.score = builder.score;
|
131 | 132 | this.explanation = builder.explanation;
|
132 | 133 | this.fields = ApiTypeHelper.unmodifiable(builder.fields);
|
@@ -160,8 +161,9 @@ public final String index() {
|
160 | 161 | }
|
161 | 162 |
|
162 | 163 | /**
|
163 |
| - * Required - API name: {@code _id} |
| 164 | + * API name: {@code _id} |
164 | 165 | */
|
| 166 | + @Nullable |
165 | 167 | public final String id() {
|
166 | 168 | return this.id;
|
167 | 169 | }
|
@@ -311,9 +313,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
|
311 | 313 | generator.writeKey("_index");
|
312 | 314 | generator.write(this.index);
|
313 | 315 |
|
314 |
| - generator.writeKey("_id"); |
315 |
| - generator.write(this.id); |
| 316 | + if (this.id != null) { |
| 317 | + generator.writeKey("_id"); |
| 318 | + generator.write(this.id); |
316 | 319 |
|
| 320 | + } |
317 | 321 | if (this.score != null) {
|
318 | 322 | generator.writeKey("_score");
|
319 | 323 | JsonpUtils.serializeDoubleOrNull(generator, this.score, Double.NaN);
|
@@ -470,6 +474,7 @@ public static class Builder<TDocument> extends WithJsonObjectBuilderBase<Builder
|
470 | 474 | ObjectBuilder<Hit<TDocument>> {
|
471 | 475 | private String index;
|
472 | 476 |
|
| 477 | + @Nullable |
473 | 478 | private String id;
|
474 | 479 |
|
475 | 480 | @Nullable
|
@@ -535,9 +540,9 @@ public final Builder<TDocument> index(String value) {
|
535 | 540 | }
|
536 | 541 |
|
537 | 542 | /**
|
538 |
| - * Required - API name: {@code _id} |
| 543 | + * API name: {@code _id} |
539 | 544 | */
|
540 |
| - public final Builder<TDocument> id(String value) { |
| 545 | + public final Builder<TDocument> id(@Nullable String value) { |
541 | 546 | this.id = value;
|
542 | 547 | return this;
|
543 | 548 | }
|
|
0 commit comments