Skip to content

Commit f2423d2

Browse files
committed
[codegen] update to latest spec
1 parent 50c6cfa commit f2423d2

File tree

3 files changed

+66
-46
lines changed

3 files changed

+66
-46
lines changed

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/SortOptions.java

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -302,48 +302,57 @@ public SortOptions build() {
302302
return new SortOptions(this);
303303
}
304304

305+
@Override
306+
public Builder withJson(JsonParser parser, JsonpMapper mapper) {
307+
deserializeBuilder(this, parser.next(), parser, mapper);
308+
return this;
309+
}
305310
}
306311

307312
public static final JsonpDeserializer<SortOptions> _DESERIALIZER = JsonpDeserializer.lazy(() -> JsonpDeserializer
308313
.of(EnumSet.of(JsonParser.Event.START_OBJECT, JsonParser.Event.VALUE_STRING), (parser, mapper, event) -> {
309314
SortOptions.Builder b = new SortOptions.Builder();
310-
311-
if (event == JsonParser.Event.VALUE_STRING) {
312-
switch (parser.getString()) {
313-
case "_score" :
314-
b.score(s -> s);
315-
break;
316-
case "_doc" :
317-
b.doc(d -> d);
318-
break;
319-
default :
320-
b.field(f -> f.field(parser.getString()));
321-
}
322-
return b.build();
323-
}
324-
325-
JsonpUtils.expectEvent(parser, JsonParser.Event.START_OBJECT, event);
326-
JsonpUtils.expectNextEvent(parser, JsonParser.Event.KEY_NAME);
327-
switch (parser.getString()) {
328-
case "_score" :
329-
b.score(ScoreSort._DESERIALIZER.deserialize(parser, mapper));
330-
break;
331-
case "_doc" :
332-
b.doc(ScoreSort._DESERIALIZER.deserialize(parser, mapper));
333-
break;
334-
case "_geo_distance" :
335-
b.geoDistance(GeoDistanceSort._DESERIALIZER.deserialize(parser, mapper));
336-
break;
337-
case "_script" :
338-
b.script(ScriptSort._DESERIALIZER.deserialize(parser, mapper));
339-
break;
340-
default :
341-
// Consumes END_OBJECT
342-
return b.field(FieldSort._DESERIALIZER.deserialize(parser, mapper, JsonParser.Event.KEY_NAME))
343-
.build();
344-
}
345-
346-
JsonpUtils.expectNextEvent(parser, JsonParser.Event.END_OBJECT);
315+
deserializeBuilder(b, event, parser, mapper);
347316
return b.build();
348317
}));
318+
319+
private static void deserializeBuilder(SortOptions.Builder b, JsonParser.Event event, JsonParser parser,
320+
JsonpMapper mapper) {
321+
if (event == JsonParser.Event.VALUE_STRING) {
322+
switch (parser.getString()) {
323+
case "_score" :
324+
b.score(s -> s);
325+
break;
326+
case "_doc" :
327+
b.doc(d -> d);
328+
break;
329+
default :
330+
b.field(f -> f.field(parser.getString()));
331+
}
332+
return;
333+
}
334+
335+
JsonpUtils.expectEvent(parser, JsonParser.Event.START_OBJECT, event);
336+
JsonpUtils.expectNextEvent(parser, JsonParser.Event.KEY_NAME);
337+
switch (parser.getString()) {
338+
case "_score" :
339+
b.score(ScoreSort._DESERIALIZER.deserialize(parser, mapper));
340+
break;
341+
case "_doc" :
342+
b.doc(ScoreSort._DESERIALIZER.deserialize(parser, mapper));
343+
break;
344+
case "_geo_distance" :
345+
b.geoDistance(GeoDistanceSort._DESERIALIZER.deserialize(parser, mapper));
346+
break;
347+
case "_script" :
348+
b.script(ScriptSort._DESERIALIZER.deserialize(parser, mapper));
349+
break;
350+
default :
351+
// Consumes END_OBJECT
352+
b.field(FieldSort._DESERIALIZER.deserialize(parser, mapper, JsonParser.Event.KEY_NAME));
353+
return;
354+
}
355+
356+
JsonpUtils.expectNextEvent(parser, JsonParser.Event.END_OBJECT);
357+
}
349358
}

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/TextEmbedding.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
*/
6060
@JsonpDeserializable
6161
public class TextEmbedding implements QueryVectorBuilderVariant, JsonpSerializable {
62+
@Nullable
6263
private final String modelId;
6364

6465
private final String modelText;
@@ -67,7 +68,7 @@ public class TextEmbedding implements QueryVectorBuilderVariant, JsonpSerializab
6768

6869
private TextEmbedding(Builder builder) {
6970

70-
this.modelId = ApiTypeHelper.requireNonNull(builder.modelId, this, "modelId");
71+
this.modelId = builder.modelId;
7172
this.modelText = ApiTypeHelper.requireNonNull(builder.modelText, this, "modelText");
7273

7374
}
@@ -85,8 +86,12 @@ public QueryVectorBuilder.Kind _queryVectorBuilderKind() {
8586
}
8687

8788
/**
88-
* Required - API name: {@code model_id}
89+
* Model ID is required for all dense_vector fields but may be inferred for
90+
* semantic_text fields
91+
* <p>
92+
* API name: {@code model_id}
8993
*/
94+
@Nullable
9095
public final String modelId() {
9196
return this.modelId;
9297
}
@@ -109,9 +114,11 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
109114

110115
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
111116

112-
generator.writeKey("model_id");
113-
generator.write(this.modelId);
117+
if (this.modelId != null) {
118+
generator.writeKey("model_id");
119+
generator.write(this.modelId);
114120

121+
}
115122
generator.writeKey("model_text");
116123
generator.write(this.modelText);
117124

@@ -129,14 +136,18 @@ public String toString() {
129136
*/
130137

131138
public static class Builder extends WithJsonObjectBuilderBase<Builder> implements ObjectBuilder<TextEmbedding> {
139+
@Nullable
132140
private String modelId;
133141

134142
private String modelText;
135143

136144
/**
137-
* Required - API name: {@code model_id}
145+
* Model ID is required for all dense_vector fields but may be inferred for
146+
* semantic_text fields
147+
* <p>
148+
* API name: {@code model_id}
138149
*/
139-
public final Builder modelId(String value) {
150+
public final Builder modelId(@Nullable String value) {
140151
this.modelId = value;
141152
return this;
142153
}

java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@
369369
'_types.StoredScript': '_types/Scripting.ts#L47-L59',
370370
'_types.SuggestMode': '_types/common.ts#L288-L301',
371371
'_types.TaskFailure': '_types/Errors.ts#L71-L76',
372-
'_types.TextEmbedding': '_types/Knn.ts#L94-L97',
372+
'_types.TextEmbedding': '_types/Knn.ts#L94-L103',
373373
'_types.TextSimilarityReranker': '_types/Retriever.ts#L140-L151',
374374
'_types.ThreadType': '_types/common.ts#L303-L309',
375375
'_types.TimeUnit': '_types/Time.ts#L69-L77',
@@ -3298,10 +3298,10 @@
32983298
if (hash.length > 1) {
32993299
hash = hash.substring(1);
33003300
}
3301-
window.location = "https://github.com/elastic/elasticsearch-specification/tree/b06a808c252f94705e34b7ffddb565c628031a1d/specification/" + (paths[hash] || "");
3301+
window.location = "https://github.com/elastic/elasticsearch-specification/tree/ba9929c3141f0d29bb092ce830eeeaa605e64240/specification/" + (paths[hash] || "");
33023302
</script>
33033303
</head>
33043304
<body>
3305-
Please see the <a href="https://github.com/elastic/elasticsearch-specification/tree/b06a808c252f94705e34b7ffddb565c628031a1d/specification/">Elasticsearch API specification</a>.
3305+
Please see the <a href="https://github.com/elastic/elasticsearch-specification/tree/ba9929c3141f0d29bb092ce830eeeaa605e64240/specification/">Elasticsearch API specification</a>.
33063306
</body>
33073307
</html>

0 commit comments

Comments
 (0)