@@ -29,18 +29,47 @@ namespace Elastic.Clients.Elasticsearch.Mapping;
29
29
30
30
public sealed partial class DenseVectorProperty : IProperty
31
31
{
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>
32
38
[ JsonInclude , JsonPropertyName ( "dims" ) ]
33
39
public int ? Dims { get ; set ; }
34
40
[ JsonInclude , JsonPropertyName ( "dynamic" ) ]
35
41
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>
36
48
[ JsonInclude , JsonPropertyName ( "element_type" ) ]
37
- public string ? ElementType { get ; set ; }
49
+ public Elastic . Clients . Elasticsearch . Mapping . DenseVectorElementType ? ElementType { get ; set ; }
38
50
[ JsonInclude , JsonPropertyName ( "fields" ) ]
39
51
public Elastic . Clients . Elasticsearch . Mapping . Properties ? Fields { get ; set ; }
40
52
[ JsonInclude , JsonPropertyName ( "ignore_above" ) ]
41
53
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>
42
60
[ JsonInclude , JsonPropertyName ( "index" ) ]
43
61
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>
44
73
[ JsonInclude , JsonPropertyName ( "index_options" ) ]
45
74
public Elastic . Clients . Elasticsearch . Mapping . DenseVectorIndexOptions ? IndexOptions { get ; set ; }
46
75
@@ -53,8 +82,28 @@ public sealed partial class DenseVectorProperty : IProperty
53
82
public IDictionary < string , string > ? Meta { get ; set ; }
54
83
[ JsonInclude , JsonPropertyName ( "properties" ) ]
55
84
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>
56
105
[ JsonInclude , JsonPropertyName ( "similarity" ) ]
57
- public string ? Similarity { get ; set ; }
106
+ public Elastic . Clients . Elasticsearch . Mapping . DenseVectorSimilarity ? Similarity { get ; set ; }
58
107
[ JsonInclude , JsonPropertyName ( "synthetic_source_keep" ) ]
59
108
public Elastic . Clients . Elasticsearch . Mapping . SyntheticSourceKeepEnum ? SyntheticSourceKeep { get ; set ; }
60
109
@@ -72,7 +121,7 @@ public DenseVectorPropertyDescriptor() : base()
72
121
73
122
private int ? DimsValue { get ; set ; }
74
123
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 ; }
76
125
private Elastic . Clients . Elasticsearch . Mapping . Properties ? FieldsValue { get ; set ; }
77
126
private int ? IgnoreAboveValue { get ; set ; }
78
127
private bool ? IndexValue { get ; set ; }
@@ -81,9 +130,15 @@ public DenseVectorPropertyDescriptor() : base()
81
130
private Action < Elastic . Clients . Elasticsearch . Mapping . DenseVectorIndexOptionsDescriptor > IndexOptionsDescriptorAction { get ; set ; }
82
131
private IDictionary < string , string > ? MetaValue { get ; set ; }
83
132
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 ; }
85
134
private Elastic . Clients . Elasticsearch . Mapping . SyntheticSourceKeepEnum ? SyntheticSourceKeepValue { get ; set ; }
86
135
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>
87
142
public DenseVectorPropertyDescriptor < TDocument > Dims ( int ? dims )
88
143
{
89
144
DimsValue = dims ;
@@ -96,7 +151,12 @@ public DenseVectorPropertyDescriptor<TDocument> Dynamic(Elastic.Clients.Elastics
96
151
return Self ;
97
152
}
98
153
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 )
100
160
{
101
161
ElementTypeValue = elementType ;
102
162
return Self ;
@@ -128,12 +188,27 @@ public DenseVectorPropertyDescriptor<TDocument> IgnoreAbove(int? ignoreAbove)
128
188
return Self ;
129
189
}
130
190
191
+ /// <summary>
192
+ /// <para>
193
+ /// If <c>true</c>, you can search this field using the kNN search API.
194
+ /// </para>
195
+ /// </summary>
131
196
public DenseVectorPropertyDescriptor < TDocument > Index ( bool ? index = true )
132
197
{
133
198
IndexValue = index ;
134
199
return Self ;
135
200
}
136
201
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>
137
212
public DenseVectorPropertyDescriptor < TDocument > IndexOptions ( Elastic . Clients . Elasticsearch . Mapping . DenseVectorIndexOptions ? indexOptions )
138
213
{
139
214
IndexOptionsDescriptor = null ;
@@ -189,7 +264,26 @@ public DenseVectorPropertyDescriptor<TDocument> Properties(Action<Elastic.Client
189
264
return Self ;
190
265
}
191
266
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 )
193
287
{
194
288
SimilarityValue = similarity ;
195
289
return Self ;
@@ -216,10 +310,10 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
216
310
JsonSerializer . Serialize ( writer , DynamicValue , options ) ;
217
311
}
218
312
219
- if ( ! string . IsNullOrEmpty ( ElementTypeValue ) )
313
+ if ( ElementTypeValue is not null )
220
314
{
221
315
writer . WritePropertyName ( "element_type" ) ;
222
- writer . WriteStringValue ( ElementTypeValue ) ;
316
+ JsonSerializer . Serialize ( writer , ElementTypeValue , options ) ;
223
317
}
224
318
225
319
if ( FieldsValue is not null )
@@ -268,10 +362,10 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
268
362
JsonSerializer . Serialize ( writer , PropertiesValue , options ) ;
269
363
}
270
364
271
- if ( ! string . IsNullOrEmpty ( SimilarityValue ) )
365
+ if ( SimilarityValue is not null )
272
366
{
273
367
writer . WritePropertyName ( "similarity" ) ;
274
- writer . WriteStringValue ( SimilarityValue ) ;
368
+ JsonSerializer . Serialize ( writer , SimilarityValue , options ) ;
275
369
}
276
370
277
371
if ( SyntheticSourceKeepValue is not null )
@@ -335,7 +429,7 @@ public DenseVectorPropertyDescriptor() : base()
335
429
336
430
private int ? DimsValue { get ; set ; }
337
431
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 ; }
339
433
private Elastic . Clients . Elasticsearch . Mapping . Properties ? FieldsValue { get ; set ; }
340
434
private int ? IgnoreAboveValue { get ; set ; }
341
435
private bool ? IndexValue { get ; set ; }
@@ -344,9 +438,15 @@ public DenseVectorPropertyDescriptor() : base()
344
438
private Action < Elastic . Clients . Elasticsearch . Mapping . DenseVectorIndexOptionsDescriptor > IndexOptionsDescriptorAction { get ; set ; }
345
439
private IDictionary < string , string > ? MetaValue { get ; set ; }
346
440
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 ; }
348
442
private Elastic . Clients . Elasticsearch . Mapping . SyntheticSourceKeepEnum ? SyntheticSourceKeepValue { get ; set ; }
349
443
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>
350
450
public DenseVectorPropertyDescriptor Dims ( int ? dims )
351
451
{
352
452
DimsValue = dims ;
@@ -359,7 +459,12 @@ public DenseVectorPropertyDescriptor Dynamic(Elastic.Clients.Elasticsearch.Mappi
359
459
return Self ;
360
460
}
361
461
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 )
363
468
{
364
469
ElementTypeValue = elementType ;
365
470
return Self ;
@@ -391,12 +496,27 @@ public DenseVectorPropertyDescriptor IgnoreAbove(int? ignoreAbove)
391
496
return Self ;
392
497
}
393
498
499
+ /// <summary>
500
+ /// <para>
501
+ /// If <c>true</c>, you can search this field using the kNN search API.
502
+ /// </para>
503
+ /// </summary>
394
504
public DenseVectorPropertyDescriptor Index ( bool ? index = true )
395
505
{
396
506
IndexValue = index ;
397
507
return Self ;
398
508
}
399
509
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>
400
520
public DenseVectorPropertyDescriptor IndexOptions ( Elastic . Clients . Elasticsearch . Mapping . DenseVectorIndexOptions ? indexOptions )
401
521
{
402
522
IndexOptionsDescriptor = null ;
@@ -452,7 +572,26 @@ public DenseVectorPropertyDescriptor Properties<TDocument>(Action<Elastic.Client
452
572
return Self ;
453
573
}
454
574
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 )
456
595
{
457
596
SimilarityValue = similarity ;
458
597
return Self ;
@@ -479,10 +618,10 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
479
618
JsonSerializer . Serialize ( writer , DynamicValue , options ) ;
480
619
}
481
620
482
- if ( ! string . IsNullOrEmpty ( ElementTypeValue ) )
621
+ if ( ElementTypeValue is not null )
483
622
{
484
623
writer . WritePropertyName ( "element_type" ) ;
485
- writer . WriteStringValue ( ElementTypeValue ) ;
624
+ JsonSerializer . Serialize ( writer , ElementTypeValue , options ) ;
486
625
}
487
626
488
627
if ( FieldsValue is not null )
@@ -531,10 +670,10 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
531
670
JsonSerializer . Serialize ( writer , PropertiesValue , options ) ;
532
671
}
533
672
534
- if ( ! string . IsNullOrEmpty ( SimilarityValue ) )
673
+ if ( SimilarityValue is not null )
535
674
{
536
675
writer . WritePropertyName ( "similarity" ) ;
537
- writer . WriteStringValue ( SimilarityValue ) ;
676
+ JsonSerializer . Serialize ( writer , SimilarityValue , options ) ;
538
677
}
539
678
540
679
if ( SyntheticSourceKeepValue is not null )
0 commit comments