Skip to content

Commit e2be39e

Browse files
committed
[codegen] update to latest spec (+ fixed esql adapter)
1 parent da50763 commit e2be39e

File tree

15 files changed

+1013
-47
lines changed

15 files changed

+1013
-47
lines changed

java-client/src/main/java/co/elastic/clients/elasticsearch/_helpers/esql/EsqlHelper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import co.elastic.clients.elasticsearch.esql.ElasticsearchEsqlAsyncClient;
2424
import co.elastic.clients.elasticsearch.esql.ElasticsearchEsqlClient;
2525
import co.elastic.clients.elasticsearch.esql.QueryRequest;
26+
import co.elastic.clients.elasticsearch.esql.query.EsqlFormat;
2627
import co.elastic.clients.json.JsonData;
2728
import co.elastic.clients.transport.endpoints.BinaryResponse;
2829

@@ -81,7 +82,7 @@ private static <T> CompletableFuture<T> doQueryAsync(
8182

8283
private static QueryRequest buildRequest(EsqlAdapter<?> adapter, String query, Object... params) {
8384
return QueryRequest.of(esql -> esql
84-
.format(adapter.format())
85+
.format(EsqlFormat._DESERIALIZER.parse(adapter.format()))
8586
.columnar(adapter.columnar())
8687
.query(query)
8788
.params(asFieldValues(params))
@@ -91,7 +92,7 @@ private static QueryRequest buildRequest(EsqlAdapter<?> adapter, String query, O
9192
private static QueryRequest buildRequest(EsqlAdapter<?> adapter, QueryRequest request) {
9293
return QueryRequest.of(q -> q
9394
// Set/override format and columnar
94-
.format(adapter.format())
95+
.format(EsqlFormat._DESERIALIZER.parse(adapter.format()))
9596
.columnar(adapter.columnar())
9697

9798
.delimiter(request.delimiter())
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package co.elastic.clients.elasticsearch._types.analysis;
21+
22+
import co.elastic.clients.json.JsonpDeserializable;
23+
import co.elastic.clients.json.JsonpDeserializer;
24+
import co.elastic.clients.json.JsonpMapper;
25+
import co.elastic.clients.json.ObjectBuilderDeserializer;
26+
import co.elastic.clients.json.ObjectDeserializer;
27+
import co.elastic.clients.util.ObjectBuilder;
28+
import jakarta.json.stream.JsonGenerator;
29+
import java.lang.Integer;
30+
import java.util.Objects;
31+
import java.util.function.Function;
32+
import javax.annotation.Nullable;
33+
34+
//----------------------------------------------------------------
35+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
36+
//----------------------------------------------------------------
37+
//
38+
// This code is generated from the Elasticsearch API specification
39+
// at https://github.com/elastic/elasticsearch-specification
40+
//
41+
// Manual updates to this file will be lost when the code is
42+
// re-generated.
43+
//
44+
// If you find a property that is missing or wrongly typed, please
45+
// open an issue or a PR on the API specification repository.
46+
//
47+
//----------------------------------------------------------------
48+
49+
// typedef: _types.analysis.ClassicTokenizer
50+
51+
/**
52+
*
53+
* @see <a href=
54+
* "../../doc-files/api-spec.html#_types.analysis.ClassicTokenizer">API
55+
* specification</a>
56+
*/
57+
@JsonpDeserializable
58+
public class ClassicTokenizer extends TokenizerBase implements TokenizerDefinitionVariant {
59+
@Nullable
60+
private final Integer maxTokenLength;
61+
62+
// ---------------------------------------------------------------------------------------------
63+
64+
private ClassicTokenizer(Builder builder) {
65+
super(builder);
66+
67+
this.maxTokenLength = builder.maxTokenLength;
68+
69+
}
70+
71+
public static ClassicTokenizer of(Function<Builder, ObjectBuilder<ClassicTokenizer>> fn) {
72+
return fn.apply(new Builder()).build();
73+
}
74+
75+
/**
76+
* TokenizerDefinition variant kind.
77+
*/
78+
@Override
79+
public TokenizerDefinition.Kind _tokenizerDefinitionKind() {
80+
return TokenizerDefinition.Kind.Classic;
81+
}
82+
83+
/**
84+
* API name: {@code max_token_length}
85+
*/
86+
@Nullable
87+
public final Integer maxTokenLength() {
88+
return this.maxTokenLength;
89+
}
90+
91+
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
92+
93+
generator.write("type", "classic");
94+
super.serializeInternal(generator, mapper);
95+
if (this.maxTokenLength != null) {
96+
generator.writeKey("max_token_length");
97+
generator.write(this.maxTokenLength);
98+
99+
}
100+
101+
}
102+
103+
// ---------------------------------------------------------------------------------------------
104+
105+
/**
106+
* Builder for {@link ClassicTokenizer}.
107+
*/
108+
109+
public static class Builder extends TokenizerBase.AbstractBuilder<Builder>
110+
implements
111+
ObjectBuilder<ClassicTokenizer> {
112+
@Nullable
113+
private Integer maxTokenLength;
114+
115+
/**
116+
* API name: {@code max_token_length}
117+
*/
118+
public final Builder maxTokenLength(@Nullable Integer value) {
119+
this.maxTokenLength = value;
120+
return this;
121+
}
122+
123+
@Override
124+
protected Builder self() {
125+
return this;
126+
}
127+
128+
/**
129+
* Builds a {@link ClassicTokenizer}.
130+
*
131+
* @throws NullPointerException
132+
* if some of the required fields are null.
133+
*/
134+
public ClassicTokenizer build() {
135+
_checkSingleUse();
136+
137+
return new ClassicTokenizer(this);
138+
}
139+
}
140+
141+
// ---------------------------------------------------------------------------------------------
142+
143+
/**
144+
* Json deserializer for {@link ClassicTokenizer}
145+
*/
146+
public static final JsonpDeserializer<ClassicTokenizer> _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new,
147+
ClassicTokenizer::setupClassicTokenizerDeserializer);
148+
149+
protected static void setupClassicTokenizerDeserializer(ObjectDeserializer<ClassicTokenizer.Builder> op) {
150+
TokenizerBase.setupTokenizerBaseDeserializer(op);
151+
op.add(Builder::maxTokenLength, JsonpDeserializer.integerDeserializer(), "max_token_length");
152+
153+
op.ignore("type");
154+
}
155+
156+
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private EdgeNGramTokenizer(Builder builder) {
7676
this.customTokenChars = builder.customTokenChars;
7777
this.maxGram = ApiTypeHelper.requireNonNull(builder.maxGram, this, "maxGram");
7878
this.minGram = ApiTypeHelper.requireNonNull(builder.minGram, this, "minGram");
79-
this.tokenChars = ApiTypeHelper.unmodifiableRequired(builder.tokenChars, this, "tokenChars");
79+
this.tokenChars = ApiTypeHelper.unmodifiable(builder.tokenChars);
8080

8181
}
8282

@@ -115,7 +115,7 @@ public final int minGram() {
115115
}
116116

117117
/**
118-
* Required - API name: {@code token_chars}
118+
* API name: {@code token_chars}
119119
*/
120120
public final List<TokenChar> tokenChars() {
121121
return this.tokenChars;
@@ -164,6 +164,7 @@ public static class Builder extends TokenizerBase.AbstractBuilder<Builder>
164164

165165
private Integer minGram;
166166

167+
@Nullable
167168
private List<TokenChar> tokenChars;
168169

169170
/**
@@ -191,7 +192,7 @@ public final Builder minGram(int value) {
191192
}
192193

193194
/**
194-
* Required - API name: {@code token_chars}
195+
* API name: {@code token_chars}
195196
* <p>
196197
* Adds all elements of <code>list</code> to <code>tokenChars</code>.
197198
*/
@@ -201,7 +202,7 @@ public final Builder tokenChars(List<TokenChar> list) {
201202
}
202203

203204
/**
204-
* Required - API name: {@code token_chars}
205+
* API name: {@code token_chars}
205206
* <p>
206207
* Adds one or more values to <code>tokenChars</code>.
207208
*/

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private NGramTokenizer(Builder builder) {
7676
this.customTokenChars = builder.customTokenChars;
7777
this.maxGram = ApiTypeHelper.requireNonNull(builder.maxGram, this, "maxGram");
7878
this.minGram = ApiTypeHelper.requireNonNull(builder.minGram, this, "minGram");
79-
this.tokenChars = ApiTypeHelper.unmodifiableRequired(builder.tokenChars, this, "tokenChars");
79+
this.tokenChars = ApiTypeHelper.unmodifiable(builder.tokenChars);
8080

8181
}
8282

@@ -115,7 +115,7 @@ public final int minGram() {
115115
}
116116

117117
/**
118-
* Required - API name: {@code token_chars}
118+
* API name: {@code token_chars}
119119
*/
120120
public final List<TokenChar> tokenChars() {
121121
return this.tokenChars;
@@ -164,6 +164,7 @@ public static class Builder extends TokenizerBase.AbstractBuilder<Builder>
164164

165165
private Integer minGram;
166166

167+
@Nullable
167168
private List<TokenChar> tokenChars;
168169

169170
/**
@@ -191,7 +192,7 @@ public final Builder minGram(int value) {
191192
}
192193

193194
/**
194-
* Required - API name: {@code token_chars}
195+
* API name: {@code token_chars}
195196
* <p>
196197
* Adds all elements of <code>list</code> to <code>tokenChars</code>.
197198
*/
@@ -201,7 +202,7 @@ public final Builder tokenChars(List<TokenChar> list) {
201202
}
202203

203204
/**
204-
* Required - API name: {@code token_chars}
205+
* API name: {@code token_chars}
205206
* <p>
206207
* Adds one or more values to <code>tokenChars</code>.
207208
*/

0 commit comments

Comments
 (0)