Skip to content

Commit 9b719ae

Browse files
committed
[codegen] update to latest api spec
1 parent 7b9ae17 commit 9b719ae

23 files changed

+2282
-107
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import co.elastic.clients.util.ObjectBuilder;
3232
import jakarta.json.stream.JsonGenerator;
3333
import java.lang.Float;
34-
import java.lang.Long;
34+
import java.lang.Integer;
3535
import java.lang.String;
3636
import java.util.List;
3737
import java.util.Objects;
@@ -70,7 +70,7 @@ public class KnnQuery extends QueryBase implements QueryVariant {
7070
private final QueryVectorBuilder queryVectorBuilder;
7171

7272
@Nullable
73-
private final Long numCandidates;
73+
private final Integer numCandidates;
7474

7575
private final List<Query> filter;
7676

@@ -138,7 +138,7 @@ public final QueryVectorBuilder queryVectorBuilder() {
138138
* API name: {@code num_candidates}
139139
*/
140140
@Nullable
141-
public final Long numCandidates() {
141+
public final Integer numCandidates() {
142142
return this.numCandidates;
143143
}
144144

@@ -221,7 +221,7 @@ public static class Builder extends QueryBase.AbstractBuilder<Builder> implement
221221
private QueryVectorBuilder queryVectorBuilder;
222222

223223
@Nullable
224-
private Long numCandidates;
224+
private Integer numCandidates;
225225

226226
@Nullable
227227
private List<Query> filter;
@@ -290,7 +290,7 @@ public final Builder queryVectorBuilder(
290290
* <p>
291291
* API name: {@code num_candidates}
292292
*/
293-
public final Builder numCandidates(@Nullable Long value) {
293+
public final Builder numCandidates(@Nullable Integer value) {
294294
this.numCandidates = value;
295295
return this;
296296
}
@@ -372,7 +372,7 @@ protected static void setupKnnQueryDeserializer(ObjectDeserializer<KnnQuery.Buil
372372
op.add(Builder::queryVector, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.floatDeserializer()),
373373
"query_vector");
374374
op.add(Builder::queryVectorBuilder, QueryVectorBuilder._DESERIALIZER, "query_vector_builder");
375-
op.add(Builder::numCandidates, JsonpDeserializer.longDeserializer(), "num_candidates");
375+
op.add(Builder::numCandidates, JsonpDeserializer.integerDeserializer(), "num_candidates");
376376
op.add(Builder::filter, JsonpDeserializer.arrayDeserializer(Query._DESERIALIZER), "filter");
377377
op.add(Builder::similarity, JsonpDeserializer.floatDeserializer(), "similarity");
378378

Lines changed: 343 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,343 @@
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;
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.ApiTypeHelper;
28+
import co.elastic.clients.util.ObjectBuilder;
29+
import jakarta.json.stream.JsonGenerator;
30+
import java.lang.Float;
31+
import java.lang.Integer;
32+
import java.lang.String;
33+
import java.util.List;
34+
import java.util.Objects;
35+
import java.util.function.Function;
36+
import javax.annotation.Nullable;
37+
38+
//----------------------------------------------------------------
39+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
40+
//----------------------------------------------------------------
41+
//
42+
// This code is generated from the Elasticsearch API specification
43+
// at https://github.com/elastic/elasticsearch-specification
44+
//
45+
// Manual updates to this file will be lost when the code is
46+
// re-generated.
47+
//
48+
// If you find a property that is missing or wrongly typed, please
49+
// open an issue or a PR on the API specification repository.
50+
//
51+
//----------------------------------------------------------------
52+
53+
// typedef: _types.KnnRetriever
54+
55+
/**
56+
*
57+
* @see <a href="../doc-files/api-spec.html#_types.KnnRetriever">API
58+
* specification</a>
59+
*/
60+
@JsonpDeserializable
61+
public class KnnRetriever extends RetrieverBase implements RetrieverVariant {
62+
private final String field;
63+
64+
private final List<Float> queryVector;
65+
66+
@Nullable
67+
private final QueryVectorBuilder queryVectorBuilder;
68+
69+
private final int k;
70+
71+
private final int numCandidates;
72+
73+
@Nullable
74+
private final Float similarity;
75+
76+
// ---------------------------------------------------------------------------------------------
77+
78+
private KnnRetriever(Builder builder) {
79+
super(builder);
80+
81+
this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field");
82+
this.queryVector = ApiTypeHelper.unmodifiable(builder.queryVector);
83+
this.queryVectorBuilder = builder.queryVectorBuilder;
84+
this.k = ApiTypeHelper.requireNonNull(builder.k, this, "k");
85+
this.numCandidates = ApiTypeHelper.requireNonNull(builder.numCandidates, this, "numCandidates");
86+
this.similarity = builder.similarity;
87+
88+
}
89+
90+
public static KnnRetriever of(Function<Builder, ObjectBuilder<KnnRetriever>> fn) {
91+
return fn.apply(new Builder()).build();
92+
}
93+
94+
/**
95+
* Retriever variant kind.
96+
*/
97+
@Override
98+
public Retriever.Kind _retrieverKind() {
99+
return Retriever.Kind.Knn;
100+
}
101+
102+
/**
103+
* Required - The name of the vector field to search against.
104+
* <p>
105+
* API name: {@code field}
106+
*/
107+
public final String field() {
108+
return this.field;
109+
}
110+
111+
/**
112+
* Query vector. Must have the same number of dimensions as the vector field you
113+
* are searching against. You must provide a query_vector_builder or
114+
* query_vector, but not both.
115+
* <p>
116+
* API name: {@code query_vector}
117+
*/
118+
public final List<Float> queryVector() {
119+
return this.queryVector;
120+
}
121+
122+
/**
123+
* Defines a model to build a query vector.
124+
* <p>
125+
* API name: {@code query_vector_builder}
126+
*/
127+
@Nullable
128+
public final QueryVectorBuilder queryVectorBuilder() {
129+
return this.queryVectorBuilder;
130+
}
131+
132+
/**
133+
* Required - Number of nearest neighbors to return as top hits.
134+
* <p>
135+
* API name: {@code k}
136+
*/
137+
public final int k() {
138+
return this.k;
139+
}
140+
141+
/**
142+
* Required - Number of nearest neighbor candidates to consider per shard.
143+
* <p>
144+
* API name: {@code num_candidates}
145+
*/
146+
public final int numCandidates() {
147+
return this.numCandidates;
148+
}
149+
150+
/**
151+
* The minimum similarity required for a document to be considered a match.
152+
* <p>
153+
* API name: {@code similarity}
154+
*/
155+
@Nullable
156+
public final Float similarity() {
157+
return this.similarity;
158+
}
159+
160+
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
161+
162+
super.serializeInternal(generator, mapper);
163+
generator.writeKey("field");
164+
generator.write(this.field);
165+
166+
if (ApiTypeHelper.isDefined(this.queryVector)) {
167+
generator.writeKey("query_vector");
168+
generator.writeStartArray();
169+
for (Float item0 : this.queryVector) {
170+
generator.write(item0);
171+
172+
}
173+
generator.writeEnd();
174+
175+
}
176+
if (this.queryVectorBuilder != null) {
177+
generator.writeKey("query_vector_builder");
178+
this.queryVectorBuilder.serialize(generator, mapper);
179+
180+
}
181+
generator.writeKey("k");
182+
generator.write(this.k);
183+
184+
generator.writeKey("num_candidates");
185+
generator.write(this.numCandidates);
186+
187+
if (this.similarity != null) {
188+
generator.writeKey("similarity");
189+
generator.write(this.similarity);
190+
191+
}
192+
193+
}
194+
195+
// ---------------------------------------------------------------------------------------------
196+
197+
/**
198+
* Builder for {@link KnnRetriever}.
199+
*/
200+
201+
public static class Builder extends RetrieverBase.AbstractBuilder<Builder> implements ObjectBuilder<KnnRetriever> {
202+
private String field;
203+
204+
@Nullable
205+
private List<Float> queryVector;
206+
207+
@Nullable
208+
private QueryVectorBuilder queryVectorBuilder;
209+
210+
private Integer k;
211+
212+
private Integer numCandidates;
213+
214+
@Nullable
215+
private Float similarity;
216+
217+
/**
218+
* Required - The name of the vector field to search against.
219+
* <p>
220+
* API name: {@code field}
221+
*/
222+
public final Builder field(String value) {
223+
this.field = value;
224+
return this;
225+
}
226+
227+
/**
228+
* Query vector. Must have the same number of dimensions as the vector field you
229+
* are searching against. You must provide a query_vector_builder or
230+
* query_vector, but not both.
231+
* <p>
232+
* API name: {@code query_vector}
233+
* <p>
234+
* Adds all elements of <code>list</code> to <code>queryVector</code>.
235+
*/
236+
public final Builder queryVector(List<Float> list) {
237+
this.queryVector = _listAddAll(this.queryVector, list);
238+
return this;
239+
}
240+
241+
/**
242+
* Query vector. Must have the same number of dimensions as the vector field you
243+
* are searching against. You must provide a query_vector_builder or
244+
* query_vector, but not both.
245+
* <p>
246+
* API name: {@code query_vector}
247+
* <p>
248+
* Adds one or more values to <code>queryVector</code>.
249+
*/
250+
public final Builder queryVector(Float value, Float... values) {
251+
this.queryVector = _listAdd(this.queryVector, value, values);
252+
return this;
253+
}
254+
255+
/**
256+
* Defines a model to build a query vector.
257+
* <p>
258+
* API name: {@code query_vector_builder}
259+
*/
260+
public final Builder queryVectorBuilder(@Nullable QueryVectorBuilder value) {
261+
this.queryVectorBuilder = value;
262+
return this;
263+
}
264+
265+
/**
266+
* Defines a model to build a query vector.
267+
* <p>
268+
* API name: {@code query_vector_builder}
269+
*/
270+
public final Builder queryVectorBuilder(
271+
Function<QueryVectorBuilder.Builder, ObjectBuilder<QueryVectorBuilder>> fn) {
272+
return this.queryVectorBuilder(fn.apply(new QueryVectorBuilder.Builder()).build());
273+
}
274+
275+
/**
276+
* Required - Number of nearest neighbors to return as top hits.
277+
* <p>
278+
* API name: {@code k}
279+
*/
280+
public final Builder k(int value) {
281+
this.k = value;
282+
return this;
283+
}
284+
285+
/**
286+
* Required - Number of nearest neighbor candidates to consider per shard.
287+
* <p>
288+
* API name: {@code num_candidates}
289+
*/
290+
public final Builder numCandidates(int value) {
291+
this.numCandidates = value;
292+
return this;
293+
}
294+
295+
/**
296+
* The minimum similarity required for a document to be considered a match.
297+
* <p>
298+
* API name: {@code similarity}
299+
*/
300+
public final Builder similarity(@Nullable Float value) {
301+
this.similarity = value;
302+
return this;
303+
}
304+
305+
@Override
306+
protected Builder self() {
307+
return this;
308+
}
309+
310+
/**
311+
* Builds a {@link KnnRetriever}.
312+
*
313+
* @throws NullPointerException
314+
* if some of the required fields are null.
315+
*/
316+
public KnnRetriever build() {
317+
_checkSingleUse();
318+
319+
return new KnnRetriever(this);
320+
}
321+
}
322+
323+
// ---------------------------------------------------------------------------------------------
324+
325+
/**
326+
* Json deserializer for {@link KnnRetriever}
327+
*/
328+
public static final JsonpDeserializer<KnnRetriever> _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new,
329+
KnnRetriever::setupKnnRetrieverDeserializer);
330+
331+
protected static void setupKnnRetrieverDeserializer(ObjectDeserializer<KnnRetriever.Builder> op) {
332+
RetrieverBase.setupRetrieverBaseDeserializer(op);
333+
op.add(Builder::field, JsonpDeserializer.stringDeserializer(), "field");
334+
op.add(Builder::queryVector, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.floatDeserializer()),
335+
"query_vector");
336+
op.add(Builder::queryVectorBuilder, QueryVectorBuilder._DESERIALIZER, "query_vector_builder");
337+
op.add(Builder::k, JsonpDeserializer.integerDeserializer(), "k");
338+
op.add(Builder::numCandidates, JsonpDeserializer.integerDeserializer(), "num_candidates");
339+
op.add(Builder::similarity, JsonpDeserializer.floatDeserializer(), "similarity");
340+
341+
}
342+
343+
}

0 commit comments

Comments
 (0)