Skip to content

Commit 899ccae

Browse files
github-actions[bot]flobernd
andauthoredMar 17, 2025··
Regenerate client using the latest specification (#8476) (#8477)
Co-authored-by: Florian Bernd <git@flobernd.de>
·
8.18.38.17.3
1 parent e91b1ea commit 899ccae

File tree

3 files changed

+534
-22
lines changed

3 files changed

+534
-22
lines changed
 

‎src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs‎

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,298 @@
2828

2929
namespace Elastic.Clients.Elasticsearch.Mapping;
3030

31+
[JsonConverter(typeof(DenseVectorElementTypeConverter))]
32+
public enum DenseVectorElementType
33+
{
34+
/// <summary>
35+
/// <para>
36+
/// Indexes a 4-byte floating-point value per dimension.
37+
/// </para>
38+
/// </summary>
39+
[EnumMember(Value = "float")]
40+
Float,
41+
/// <summary>
42+
/// <para>
43+
/// Indexes a 1-byte integer value per dimension.
44+
/// </para>
45+
/// </summary>
46+
[EnumMember(Value = "byte")]
47+
Byte,
48+
/// <summary>
49+
/// <para>
50+
/// Indexes a single bit per dimension. Useful for very high-dimensional vectors or models that specifically support
51+
/// bit vectors.
52+
/// </para>
53+
/// <para>
54+
/// NOTE: when using <c>bit</c>, the number of dimensions must be a multiple of <c>8</c> and must represent the number of bits.
55+
/// </para>
56+
/// </summary>
57+
[EnumMember(Value = "bit")]
58+
Bit
59+
}
60+
61+
internal sealed class DenseVectorElementTypeConverter : JsonConverter<DenseVectorElementType>
62+
{
63+
public override DenseVectorElementType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
64+
{
65+
var enumString = reader.GetString();
66+
switch (enumString)
67+
{
68+
case "float":
69+
return DenseVectorElementType.Float;
70+
case "byte":
71+
return DenseVectorElementType.Byte;
72+
case "bit":
73+
return DenseVectorElementType.Bit;
74+
}
75+
76+
ThrowHelper.ThrowJsonException();
77+
return default;
78+
}
79+
80+
public override void Write(Utf8JsonWriter writer, DenseVectorElementType value, JsonSerializerOptions options)
81+
{
82+
switch (value)
83+
{
84+
case DenseVectorElementType.Float:
85+
writer.WriteStringValue("float");
86+
return;
87+
case DenseVectorElementType.Byte:
88+
writer.WriteStringValue("byte");
89+
return;
90+
case DenseVectorElementType.Bit:
91+
writer.WriteStringValue("bit");
92+
return;
93+
}
94+
95+
writer.WriteNullValue();
96+
}
97+
}
98+
99+
[JsonConverter(typeof(DenseVectorIndexOptionsTypeConverter))]
100+
public enum DenseVectorIndexOptionsType
101+
{
102+
/// <summary>
103+
/// <para>
104+
/// The default index type for <c>float</c> vectors. This utilizes the HNSW algorithm in addition to automatically scalar
105+
/// quantization for scalable approximate kNN search with <c>element_type</c> of <c>float</c>.
106+
/// </para>
107+
/// <para>
108+
/// This can reduce the memory footprint by 4x at the cost of some accuracy.
109+
/// </para>
110+
/// </summary>
111+
[EnumMember(Value = "int8_hnsw")]
112+
Int8Hnsw,
113+
/// <summary>
114+
/// <para>
115+
/// This utilizes a brute-force search algorithm in addition to automatically scalar quantization. Only supports
116+
/// <c>element_type</c> of <c>float</c>.
117+
/// </para>
118+
/// </summary>
119+
[EnumMember(Value = "int8_flat")]
120+
Int8Flat,
121+
/// <summary>
122+
/// <para>
123+
/// This utilizes the HNSW algorithm in addition to automatically scalar quantization for scalable approximate kNN
124+
/// search with <c>element_type</c> of <c>float</c>.
125+
/// </para>
126+
/// <para>
127+
/// This can reduce the memory footprint by 8x at the cost of some accuracy.
128+
/// </para>
129+
/// </summary>
130+
[EnumMember(Value = "int4_hnsw")]
131+
Int4Hnsw,
132+
/// <summary>
133+
/// <para>
134+
/// This utilizes a brute-force search algorithm in addition to automatically half-byte scalar quantization.
135+
/// Only supports <c>element_type</c> of <c>float</c>.
136+
/// </para>
137+
/// </summary>
138+
[EnumMember(Value = "int4_flat")]
139+
Int4Flat,
140+
/// <summary>
141+
/// <para>
142+
/// This utilizes the HNSW algorithm for scalable approximate kNN search. This supports all <c>element_type</c> values.
143+
/// </para>
144+
/// </summary>
145+
[EnumMember(Value = "hnsw")]
146+
Hnsw,
147+
/// <summary>
148+
/// <para>
149+
/// This utilizes a brute-force search algorithm for exact kNN search. This supports all <c>element_type</c> values.
150+
/// </para>
151+
/// </summary>
152+
[EnumMember(Value = "flat")]
153+
Flat
154+
}
155+
156+
internal sealed class DenseVectorIndexOptionsTypeConverter : JsonConverter<DenseVectorIndexOptionsType>
157+
{
158+
public override DenseVectorIndexOptionsType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
159+
{
160+
var enumString = reader.GetString();
161+
switch (enumString)
162+
{
163+
case "int8_hnsw":
164+
return DenseVectorIndexOptionsType.Int8Hnsw;
165+
case "int8_flat":
166+
return DenseVectorIndexOptionsType.Int8Flat;
167+
case "int4_hnsw":
168+
return DenseVectorIndexOptionsType.Int4Hnsw;
169+
case "int4_flat":
170+
return DenseVectorIndexOptionsType.Int4Flat;
171+
case "hnsw":
172+
return DenseVectorIndexOptionsType.Hnsw;
173+
case "flat":
174+
return DenseVectorIndexOptionsType.Flat;
175+
}
176+
177+
ThrowHelper.ThrowJsonException();
178+
return default;
179+
}
180+
181+
public override void Write(Utf8JsonWriter writer, DenseVectorIndexOptionsType value, JsonSerializerOptions options)
182+
{
183+
switch (value)
184+
{
185+
case DenseVectorIndexOptionsType.Int8Hnsw:
186+
writer.WriteStringValue("int8_hnsw");
187+
return;
188+
case DenseVectorIndexOptionsType.Int8Flat:
189+
writer.WriteStringValue("int8_flat");
190+
return;
191+
case DenseVectorIndexOptionsType.Int4Hnsw:
192+
writer.WriteStringValue("int4_hnsw");
193+
return;
194+
case DenseVectorIndexOptionsType.Int4Flat:
195+
writer.WriteStringValue("int4_flat");
196+
return;
197+
case DenseVectorIndexOptionsType.Hnsw:
198+
writer.WriteStringValue("hnsw");
199+
return;
200+
case DenseVectorIndexOptionsType.Flat:
201+
writer.WriteStringValue("flat");
202+
return;
203+
}
204+
205+
writer.WriteNullValue();
206+
}
207+
}
208+
209+
[JsonConverter(typeof(DenseVectorSimilarityConverter))]
210+
public enum DenseVectorSimilarity
211+
{
212+
/// <summary>
213+
/// <para>
214+
/// Computes the maximum inner product of two vectors. This is similar to <c>dot_product</c>, but doesn't require vectors
215+
/// to be normalized. This means that each vector’s magnitude can significantly effect the score.
216+
/// </para>
217+
/// <para>
218+
/// The document <c>_score</c> is adjusted to prevent negative values. For <c>max_inner_product</c> values <c>&lt; 0</c>, the <c>_score</c>
219+
/// is <c>1 / (1 + -1 * max_inner_product(query, vector))</c>. For non-negative <c>max_inner_product</c> results the <c>_score</c>
220+
/// is calculated <c>max_inner_product(query, vector) + 1</c>.
221+
/// </para>
222+
/// </summary>
223+
[EnumMember(Value = "max_inner_product")]
224+
MaxInnerProduct,
225+
/// <summary>
226+
/// <para>
227+
/// Computes similarity based on the <c>L2</c> distance (also known as Euclidean distance) between the vectors.
228+
/// </para>
229+
/// <para>
230+
/// The document <c>_score</c> is computed as <c>1 / (1 + l2_norm(query, vector)^2)</c>.
231+
/// </para>
232+
/// <para>
233+
/// For <c>bit</c> vectors, instead of using <c>l2_norm</c>, the <c>hamming</c> distance between the vectors is used.
234+
/// </para>
235+
/// <para>
236+
/// The <c>_score</c> transformation is <c>(numBits - hamming(a, b)) / numBits</c>.
237+
/// </para>
238+
/// </summary>
239+
[EnumMember(Value = "l2_norm")]
240+
L2Norm,
241+
/// <summary>
242+
/// <para>
243+
/// Computes the dot product of two unit vectors. This option provides an optimized way to perform cosine similarity.
244+
/// The constraints and computed score are defined by <c>element_type</c>.
245+
/// </para>
246+
/// <para>
247+
/// When <c>element_type</c> is <c>float</c>, all vectors must be unit length, including both document and query vectors.
248+
/// </para>
249+
/// <para>
250+
/// The document <c>_score</c> is computed as <c>(1 + dot_product(query, vector)) / 2</c>.
251+
/// </para>
252+
/// <para>
253+
/// When <c>element_type</c> is <c>byte</c>, all vectors must have the same length including both document and query vectors or
254+
/// results will be inaccurate.
255+
/// </para>
256+
/// <para>
257+
/// The document <c>_score</c> is computed as <c>0.5 + (dot_product(query, vector) / (32768 * dims))</c> where <c>dims</c> is the
258+
/// number of dimensions per vector.
259+
/// </para>
260+
/// </summary>
261+
[EnumMember(Value = "dot_product")]
262+
DotProduct,
263+
/// <summary>
264+
/// <para>
265+
/// Computes the cosine similarity. During indexing Elasticsearch automatically normalizes vectors with <c>cosine</c>
266+
/// similarity to unit length. This allows to internally use <c>dot_product</c> for computing similarity, which is more
267+
/// efficient. Original un-normalized vectors can be still accessed through scripts.
268+
/// </para>
269+
/// <para>
270+
/// The document <c>_score</c> is computed as <c>(1 + cosine(query, vector)) / 2</c>.
271+
/// </para>
272+
/// <para>
273+
/// The <c>cosine</c> similarity does not allow vectors with zero magnitude, since cosine is not defined in this case.
274+
/// </para>
275+
/// </summary>
276+
[EnumMember(Value = "cosine")]
277+
Cosine
278+
}
279+
280+
internal sealed class DenseVectorSimilarityConverter : JsonConverter<DenseVectorSimilarity>
281+
{
282+
public override DenseVectorSimilarity Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
283+
{
284+
var enumString = reader.GetString();
285+
switch (enumString)
286+
{
287+
case "max_inner_product":
288+
return DenseVectorSimilarity.MaxInnerProduct;
289+
case "l2_norm":
290+
return DenseVectorSimilarity.L2Norm;
291+
case "dot_product":
292+
return DenseVectorSimilarity.DotProduct;
293+
case "cosine":
294+
return DenseVectorSimilarity.Cosine;
295+
}
296+
297+
ThrowHelper.ThrowJsonException();
298+
return default;
299+
}
300+
301+
public override void Write(Utf8JsonWriter writer, DenseVectorSimilarity value, JsonSerializerOptions options)
302+
{
303+
switch (value)
304+
{
305+
case DenseVectorSimilarity.MaxInnerProduct:
306+
writer.WriteStringValue("max_inner_product");
307+
return;
308+
case DenseVectorSimilarity.L2Norm:
309+
writer.WriteStringValue("l2_norm");
310+
return;
311+
case DenseVectorSimilarity.DotProduct:
312+
writer.WriteStringValue("dot_product");
313+
return;
314+
case DenseVectorSimilarity.Cosine:
315+
writer.WriteStringValue("cosine");
316+
return;
317+
}
318+
319+
writer.WriteNullValue();
320+
}
321+
}
322+
31323
[JsonConverter(typeof(DynamicMappingConverter))]
32324
public enum DynamicMapping
33325
{

‎src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DenseVectorIndexOptions.g.cs‎

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,56 @@ namespace Elastic.Clients.Elasticsearch.Mapping;
2929

3030
public sealed partial class DenseVectorIndexOptions
3131
{
32+
/// <summary>
33+
/// <para>
34+
/// The confidence interval to use when quantizing the vectors. Can be any value between and including <c>0.90</c> and
35+
/// <c>1.0</c> or exactly <c>0</c>. When the value is <c>0</c>, this indicates that dynamic quantiles should be calculated for
36+
/// optimized quantization. When between <c>0.90</c> and <c>1.0</c>, this value restricts the values used when calculating
37+
/// the quantization thresholds.
38+
/// </para>
39+
/// <para>
40+
/// For example, a value of <c>0.95</c> will only use the middle <c>95%</c> of the values when calculating the quantization
41+
/// thresholds (e.g. the highest and lowest <c>2.5%</c> of values will be ignored).
42+
/// </para>
43+
/// <para>
44+
/// Defaults to <c>1/(dims + 1)</c> for <c>int8</c> quantized vectors and <c>0</c> for <c>int4</c> for dynamic quantile calculation.
45+
/// </para>
46+
/// <para>
47+
/// Only applicable to <c>int8_hnsw</c>, <c>int4_hnsw</c>, <c>int8_flat</c>, and <c>int4_flat</c> index types.
48+
/// </para>
49+
/// </summary>
3250
[JsonInclude, JsonPropertyName("confidence_interval")]
3351
public float? ConfidenceInterval { get; set; }
52+
53+
/// <summary>
54+
/// <para>
55+
/// The number of candidates to track while assembling the list of nearest neighbors for each new node.
56+
/// </para>
57+
/// <para>
58+
/// Only applicable to <c>hnsw</c>, <c>int8_hnsw</c>, and <c>int4_hnsw</c> index types.
59+
/// </para>
60+
/// </summary>
3461
[JsonInclude, JsonPropertyName("ef_construction")]
3562
public int? EfConstruction { get; set; }
63+
64+
/// <summary>
65+
/// <para>
66+
/// The number of neighbors each node will be connected to in the HNSW graph.
67+
/// </para>
68+
/// <para>
69+
/// Only applicable to <c>hnsw</c>, <c>int8_hnsw</c>, and <c>int4_hnsw</c> index types.
70+
/// </para>
71+
/// </summary>
3672
[JsonInclude, JsonPropertyName("m")]
3773
public int? m { get; set; }
74+
75+
/// <summary>
76+
/// <para>
77+
/// The type of kNN algorithm to use.
78+
/// </para>
79+
/// </summary>
3880
[JsonInclude, JsonPropertyName("type")]
39-
public string Type { get; set; }
81+
public Elastic.Clients.Elasticsearch.Mapping.DenseVectorIndexOptionsType Type { get; set; }
4082
}
4183

4284
public sealed partial class DenseVectorIndexOptionsDescriptor : SerializableDescriptor<DenseVectorIndexOptionsDescriptor>
@@ -50,27 +92,66 @@ public DenseVectorIndexOptionsDescriptor() : base()
5092
private float? ConfidenceIntervalValue { get; set; }
5193
private int? EfConstructionValue { get; set; }
5294
private int? mValue { get; set; }
53-
private string TypeValue { get; set; }
95+
private Elastic.Clients.Elasticsearch.Mapping.DenseVectorIndexOptionsType TypeValue { get; set; }
5496

97+
/// <summary>
98+
/// <para>
99+
/// The confidence interval to use when quantizing the vectors. Can be any value between and including <c>0.90</c> and
100+
/// <c>1.0</c> or exactly <c>0</c>. When the value is <c>0</c>, this indicates that dynamic quantiles should be calculated for
101+
/// optimized quantization. When between <c>0.90</c> and <c>1.0</c>, this value restricts the values used when calculating
102+
/// the quantization thresholds.
103+
/// </para>
104+
/// <para>
105+
/// For example, a value of <c>0.95</c> will only use the middle <c>95%</c> of the values when calculating the quantization
106+
/// thresholds (e.g. the highest and lowest <c>2.5%</c> of values will be ignored).
107+
/// </para>
108+
/// <para>
109+
/// Defaults to <c>1/(dims + 1)</c> for <c>int8</c> quantized vectors and <c>0</c> for <c>int4</c> for dynamic quantile calculation.
110+
/// </para>
111+
/// <para>
112+
/// Only applicable to <c>int8_hnsw</c>, <c>int4_hnsw</c>, <c>int8_flat</c>, and <c>int4_flat</c> index types.
113+
/// </para>
114+
/// </summary>
55115
public DenseVectorIndexOptionsDescriptor ConfidenceInterval(float? confidenceInterval)
56116
{
57117
ConfidenceIntervalValue = confidenceInterval;
58118
return Self;
59119
}
60120

121+
/// <summary>
122+
/// <para>
123+
/// The number of candidates to track while assembling the list of nearest neighbors for each new node.
124+
/// </para>
125+
/// <para>
126+
/// Only applicable to <c>hnsw</c>, <c>int8_hnsw</c>, and <c>int4_hnsw</c> index types.
127+
/// </para>
128+
/// </summary>
61129
public DenseVectorIndexOptionsDescriptor EfConstruction(int? efConstruction)
62130
{
63131
EfConstructionValue = efConstruction;
64132
return Self;
65133
}
66134

135+
/// <summary>
136+
/// <para>
137+
/// The number of neighbors each node will be connected to in the HNSW graph.
138+
/// </para>
139+
/// <para>
140+
/// Only applicable to <c>hnsw</c>, <c>int8_hnsw</c>, and <c>int4_hnsw</c> index types.
141+
/// </para>
142+
/// </summary>
67143
public DenseVectorIndexOptionsDescriptor m(int? m)
68144
{
69145
mValue = m;
70146
return Self;
71147
}
72148

73-
public DenseVectorIndexOptionsDescriptor Type(string type)
149+
/// <summary>
150+
/// <para>
151+
/// The type of kNN algorithm to use.
152+
/// </para>
153+
/// </summary>
154+
public DenseVectorIndexOptionsDescriptor Type(Elastic.Clients.Elasticsearch.Mapping.DenseVectorIndexOptionsType type)
74155
{
75156
TypeValue = type;
76157
return Self;
@@ -98,7 +179,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
98179
}
99180

100181
writer.WritePropertyName("type");
101-
writer.WriteStringValue(TypeValue);
182+
JsonSerializer.Serialize(writer, TypeValue, options);
102183
writer.WriteEndObject();
103184
}
104185
}

‎src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DenseVectorProperty.g.cs‎

Lines changed: 157 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,47 @@ namespace Elastic.Clients.Elasticsearch.Mapping;
2929

3030
public sealed partial class DenseVectorProperty : IProperty
3131
{
32+
/// <summary>
33+
/// <para>
34+
/// Number of vector dimensions. Can't exceed <c>4096</c>. If <c>dims</c> is not specified, it will be set to the length of
35+
/// the first vector added to the field.
36+
/// </para>
37+
/// </summary>
3238
[JsonInclude, JsonPropertyName("dims")]
3339
public int? Dims { get; set; }
3440
[JsonInclude, JsonPropertyName("dynamic")]
3541
public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; }
42+
43+
/// <summary>
44+
/// <para>
45+
/// The data type used to encode vectors. The supported data types are <c>float</c> (default), <c>byte</c>, and <c>bit</c>.
46+
/// </para>
47+
/// </summary>
3648
[JsonInclude, JsonPropertyName("element_type")]
37-
public string? ElementType { get; set; }
49+
public Elastic.Clients.Elasticsearch.Mapping.DenseVectorElementType? ElementType { get; set; }
3850
[JsonInclude, JsonPropertyName("fields")]
3951
public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; }
4052
[JsonInclude, JsonPropertyName("ignore_above")]
4153
public int? IgnoreAbove { get; set; }
54+
55+
/// <summary>
56+
/// <para>
57+
/// If <c>true</c>, you can search this field using the kNN search API.
58+
/// </para>
59+
/// </summary>
4260
[JsonInclude, JsonPropertyName("index")]
4361
public bool? Index { get; set; }
62+
63+
/// <summary>
64+
/// <para>
65+
/// An optional section that configures the kNN indexing algorithm. The HNSW algorithm has two internal parameters
66+
/// that influence how the data structure is built. These can be adjusted to improve the accuracy of results, at the
67+
/// expense of slower indexing speed.
68+
/// </para>
69+
/// <para>
70+
/// This parameter can only be specified when <c>index</c> is <c>true</c>.
71+
/// </para>
72+
/// </summary>
4473
[JsonInclude, JsonPropertyName("index_options")]
4574
public Elastic.Clients.Elasticsearch.Mapping.DenseVectorIndexOptions? IndexOptions { get; set; }
4675

@@ -53,8 +82,28 @@ public sealed partial class DenseVectorProperty : IProperty
5382
public IDictionary<string, string>? Meta { get; set; }
5483
[JsonInclude, JsonPropertyName("properties")]
5584
public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; }
85+
86+
/// <summary>
87+
/// <para>
88+
/// The vector similarity metric to use in kNN search.
89+
/// </para>
90+
/// <para>
91+
/// Documents are ranked by their vector field's similarity to the query vector. The <c>_score</c> of each document will
92+
/// be derived from the similarity, in a way that ensures scores are positive and that a larger score corresponds
93+
/// to a higher ranking.
94+
/// </para>
95+
/// <para>
96+
/// Defaults to <c>l2_norm</c> when <c>element_type</c> is <c>bit</c> otherwise defaults to <c>cosine</c>.
97+
/// </para>
98+
/// <para>
99+
/// <c>bit</c> vectors only support <c>l2_norm</c> as their similarity metric.
100+
/// </para>
101+
/// <para>
102+
/// This parameter can only be specified when <c>index</c> is <c>true</c>.
103+
/// </para>
104+
/// </summary>
56105
[JsonInclude, JsonPropertyName("similarity")]
57-
public string? Similarity { get; set; }
106+
public Elastic.Clients.Elasticsearch.Mapping.DenseVectorSimilarity? Similarity { get; set; }
58107
[JsonInclude, JsonPropertyName("synthetic_source_keep")]
59108
public Elastic.Clients.Elasticsearch.Mapping.SyntheticSourceKeepEnum? SyntheticSourceKeep { get; set; }
60109

@@ -72,7 +121,7 @@ public DenseVectorPropertyDescriptor() : base()
72121

73122
private int? DimsValue { get; set; }
74123
private Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? DynamicValue { get; set; }
75-
private string? ElementTypeValue { get; set; }
124+
private Elastic.Clients.Elasticsearch.Mapping.DenseVectorElementType? ElementTypeValue { get; set; }
76125
private Elastic.Clients.Elasticsearch.Mapping.Properties? FieldsValue { get; set; }
77126
private int? IgnoreAboveValue { get; set; }
78127
private bool? IndexValue { get; set; }
@@ -81,9 +130,15 @@ public DenseVectorPropertyDescriptor() : base()
81130
private Action<Elastic.Clients.Elasticsearch.Mapping.DenseVectorIndexOptionsDescriptor> IndexOptionsDescriptorAction { get; set; }
82131
private IDictionary<string, string>? MetaValue { get; set; }
83132
private Elastic.Clients.Elasticsearch.Mapping.Properties? PropertiesValue { get; set; }
84-
private string? SimilarityValue { get; set; }
133+
private Elastic.Clients.Elasticsearch.Mapping.DenseVectorSimilarity? SimilarityValue { get; set; }
85134
private Elastic.Clients.Elasticsearch.Mapping.SyntheticSourceKeepEnum? SyntheticSourceKeepValue { get; set; }
86135

136+
/// <summary>
137+
/// <para>
138+
/// Number of vector dimensions. Can't exceed <c>4096</c>. If <c>dims</c> is not specified, it will be set to the length of
139+
/// the first vector added to the field.
140+
/// </para>
141+
/// </summary>
87142
public DenseVectorPropertyDescriptor<TDocument> Dims(int? dims)
88143
{
89144
DimsValue = dims;
@@ -96,7 +151,12 @@ public DenseVectorPropertyDescriptor<TDocument> Dynamic(Elastic.Clients.Elastics
96151
return Self;
97152
}
98153

99-
public DenseVectorPropertyDescriptor<TDocument> ElementType(string? elementType)
154+
/// <summary>
155+
/// <para>
156+
/// The data type used to encode vectors. The supported data types are <c>float</c> (default), <c>byte</c>, and <c>bit</c>.
157+
/// </para>
158+
/// </summary>
159+
public DenseVectorPropertyDescriptor<TDocument> ElementType(Elastic.Clients.Elasticsearch.Mapping.DenseVectorElementType? elementType)
100160
{
101161
ElementTypeValue = elementType;
102162
return Self;
@@ -128,12 +188,27 @@ public DenseVectorPropertyDescriptor<TDocument> IgnoreAbove(int? ignoreAbove)
128188
return Self;
129189
}
130190

191+
/// <summary>
192+
/// <para>
193+
/// If <c>true</c>, you can search this field using the kNN search API.
194+
/// </para>
195+
/// </summary>
131196
public DenseVectorPropertyDescriptor<TDocument> Index(bool? index = true)
132197
{
133198
IndexValue = index;
134199
return Self;
135200
}
136201

202+
/// <summary>
203+
/// <para>
204+
/// An optional section that configures the kNN indexing algorithm. The HNSW algorithm has two internal parameters
205+
/// that influence how the data structure is built. These can be adjusted to improve the accuracy of results, at the
206+
/// expense of slower indexing speed.
207+
/// </para>
208+
/// <para>
209+
/// This parameter can only be specified when <c>index</c> is <c>true</c>.
210+
/// </para>
211+
/// </summary>
137212
public DenseVectorPropertyDescriptor<TDocument> IndexOptions(Elastic.Clients.Elasticsearch.Mapping.DenseVectorIndexOptions? indexOptions)
138213
{
139214
IndexOptionsDescriptor = null;
@@ -189,7 +264,26 @@ public DenseVectorPropertyDescriptor<TDocument> Properties(Action<Elastic.Client
189264
return Self;
190265
}
191266

192-
public DenseVectorPropertyDescriptor<TDocument> Similarity(string? similarity)
267+
/// <summary>
268+
/// <para>
269+
/// The vector similarity metric to use in kNN search.
270+
/// </para>
271+
/// <para>
272+
/// Documents are ranked by their vector field's similarity to the query vector. The <c>_score</c> of each document will
273+
/// be derived from the similarity, in a way that ensures scores are positive and that a larger score corresponds
274+
/// to a higher ranking.
275+
/// </para>
276+
/// <para>
277+
/// Defaults to <c>l2_norm</c> when <c>element_type</c> is <c>bit</c> otherwise defaults to <c>cosine</c>.
278+
/// </para>
279+
/// <para>
280+
/// <c>bit</c> vectors only support <c>l2_norm</c> as their similarity metric.
281+
/// </para>
282+
/// <para>
283+
/// This parameter can only be specified when <c>index</c> is <c>true</c>.
284+
/// </para>
285+
/// </summary>
286+
public DenseVectorPropertyDescriptor<TDocument> Similarity(Elastic.Clients.Elasticsearch.Mapping.DenseVectorSimilarity? similarity)
193287
{
194288
SimilarityValue = similarity;
195289
return Self;
@@ -216,10 +310,10 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
216310
JsonSerializer.Serialize(writer, DynamicValue, options);
217311
}
218312

219-
if (!string.IsNullOrEmpty(ElementTypeValue))
313+
if (ElementTypeValue is not null)
220314
{
221315
writer.WritePropertyName("element_type");
222-
writer.WriteStringValue(ElementTypeValue);
316+
JsonSerializer.Serialize(writer, ElementTypeValue, options);
223317
}
224318

225319
if (FieldsValue is not null)
@@ -268,10 +362,10 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
268362
JsonSerializer.Serialize(writer, PropertiesValue, options);
269363
}
270364

271-
if (!string.IsNullOrEmpty(SimilarityValue))
365+
if (SimilarityValue is not null)
272366
{
273367
writer.WritePropertyName("similarity");
274-
writer.WriteStringValue(SimilarityValue);
368+
JsonSerializer.Serialize(writer, SimilarityValue, options);
275369
}
276370

277371
if (SyntheticSourceKeepValue is not null)
@@ -335,7 +429,7 @@ public DenseVectorPropertyDescriptor() : base()
335429

336430
private int? DimsValue { get; set; }
337431
private Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? DynamicValue { get; set; }
338-
private string? ElementTypeValue { get; set; }
432+
private Elastic.Clients.Elasticsearch.Mapping.DenseVectorElementType? ElementTypeValue { get; set; }
339433
private Elastic.Clients.Elasticsearch.Mapping.Properties? FieldsValue { get; set; }
340434
private int? IgnoreAboveValue { get; set; }
341435
private bool? IndexValue { get; set; }
@@ -344,9 +438,15 @@ public DenseVectorPropertyDescriptor() : base()
344438
private Action<Elastic.Clients.Elasticsearch.Mapping.DenseVectorIndexOptionsDescriptor> IndexOptionsDescriptorAction { get; set; }
345439
private IDictionary<string, string>? MetaValue { get; set; }
346440
private Elastic.Clients.Elasticsearch.Mapping.Properties? PropertiesValue { get; set; }
347-
private string? SimilarityValue { get; set; }
441+
private Elastic.Clients.Elasticsearch.Mapping.DenseVectorSimilarity? SimilarityValue { get; set; }
348442
private Elastic.Clients.Elasticsearch.Mapping.SyntheticSourceKeepEnum? SyntheticSourceKeepValue { get; set; }
349443

444+
/// <summary>
445+
/// <para>
446+
/// Number of vector dimensions. Can't exceed <c>4096</c>. If <c>dims</c> is not specified, it will be set to the length of
447+
/// the first vector added to the field.
448+
/// </para>
449+
/// </summary>
350450
public DenseVectorPropertyDescriptor Dims(int? dims)
351451
{
352452
DimsValue = dims;
@@ -359,7 +459,12 @@ public DenseVectorPropertyDescriptor Dynamic(Elastic.Clients.Elasticsearch.Mappi
359459
return Self;
360460
}
361461

362-
public DenseVectorPropertyDescriptor ElementType(string? elementType)
462+
/// <summary>
463+
/// <para>
464+
/// The data type used to encode vectors. The supported data types are <c>float</c> (default), <c>byte</c>, and <c>bit</c>.
465+
/// </para>
466+
/// </summary>
467+
public DenseVectorPropertyDescriptor ElementType(Elastic.Clients.Elasticsearch.Mapping.DenseVectorElementType? elementType)
363468
{
364469
ElementTypeValue = elementType;
365470
return Self;
@@ -391,12 +496,27 @@ public DenseVectorPropertyDescriptor IgnoreAbove(int? ignoreAbove)
391496
return Self;
392497
}
393498

499+
/// <summary>
500+
/// <para>
501+
/// If <c>true</c>, you can search this field using the kNN search API.
502+
/// </para>
503+
/// </summary>
394504
public DenseVectorPropertyDescriptor Index(bool? index = true)
395505
{
396506
IndexValue = index;
397507
return Self;
398508
}
399509

510+
/// <summary>
511+
/// <para>
512+
/// An optional section that configures the kNN indexing algorithm. The HNSW algorithm has two internal parameters
513+
/// that influence how the data structure is built. These can be adjusted to improve the accuracy of results, at the
514+
/// expense of slower indexing speed.
515+
/// </para>
516+
/// <para>
517+
/// This parameter can only be specified when <c>index</c> is <c>true</c>.
518+
/// </para>
519+
/// </summary>
400520
public DenseVectorPropertyDescriptor IndexOptions(Elastic.Clients.Elasticsearch.Mapping.DenseVectorIndexOptions? indexOptions)
401521
{
402522
IndexOptionsDescriptor = null;
@@ -452,7 +572,26 @@ public DenseVectorPropertyDescriptor Properties<TDocument>(Action<Elastic.Client
452572
return Self;
453573
}
454574

455-
public DenseVectorPropertyDescriptor Similarity(string? similarity)
575+
/// <summary>
576+
/// <para>
577+
/// The vector similarity metric to use in kNN search.
578+
/// </para>
579+
/// <para>
580+
/// Documents are ranked by their vector field's similarity to the query vector. The <c>_score</c> of each document will
581+
/// be derived from the similarity, in a way that ensures scores are positive and that a larger score corresponds
582+
/// to a higher ranking.
583+
/// </para>
584+
/// <para>
585+
/// Defaults to <c>l2_norm</c> when <c>element_type</c> is <c>bit</c> otherwise defaults to <c>cosine</c>.
586+
/// </para>
587+
/// <para>
588+
/// <c>bit</c> vectors only support <c>l2_norm</c> as their similarity metric.
589+
/// </para>
590+
/// <para>
591+
/// This parameter can only be specified when <c>index</c> is <c>true</c>.
592+
/// </para>
593+
/// </summary>
594+
public DenseVectorPropertyDescriptor Similarity(Elastic.Clients.Elasticsearch.Mapping.DenseVectorSimilarity? similarity)
456595
{
457596
SimilarityValue = similarity;
458597
return Self;
@@ -479,10 +618,10 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
479618
JsonSerializer.Serialize(writer, DynamicValue, options);
480619
}
481620

482-
if (!string.IsNullOrEmpty(ElementTypeValue))
621+
if (ElementTypeValue is not null)
483622
{
484623
writer.WritePropertyName("element_type");
485-
writer.WriteStringValue(ElementTypeValue);
624+
JsonSerializer.Serialize(writer, ElementTypeValue, options);
486625
}
487626

488627
if (FieldsValue is not null)
@@ -531,10 +670,10 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
531670
JsonSerializer.Serialize(writer, PropertiesValue, options);
532671
}
533672

534-
if (!string.IsNullOrEmpty(SimilarityValue))
673+
if (SimilarityValue is not null)
535674
{
536675
writer.WritePropertyName("similarity");
537-
writer.WriteStringValue(SimilarityValue);
676+
JsonSerializer.Serialize(writer, SimilarityValue, options);
538677
}
539678

540679
if (SyntheticSourceKeepValue is not null)

0 commit comments

Comments
 (0)
Please sign in to comment.