@@ -245,7 +245,7 @@ public override SearchRequest Read(ref Utf8JsonReader reader, Type typeToConvert
245
245
246
246
if ( property == "knn" )
247
247
{
248
- variant . Knn = JsonSerializer . Deserialize < Elastic . Clients . Elasticsearch . KnnQuery ? > ( ref reader , options ) ;
248
+ variant . Knn = JsonSerializer . Deserialize < ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? > ( ref reader , options ) ;
249
249
continue ;
250
250
}
251
251
@@ -824,8 +824,8 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r =>
824
824
/// <summary>
825
825
/// <para>Defines the approximate kNN search to run.</para>
826
826
/// </summary>
827
- [ JsonInclude , JsonPropertyName ( "knn" ) ]
828
- public Elastic . Clients . Elasticsearch . KnnQuery ? Knn { get ; set ; }
827
+ [ JsonInclude , JsonPropertyName ( "knn" ) , SingleOrManyCollectionConverter ( typeof ( Elastic . Clients . Elasticsearch . KnnQuery ) ) ]
828
+ public ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? Knn { get ; set ; }
829
829
830
830
/// <summary>
831
831
/// <para>Minimum _score for matching documents. Documents with a lower _score are<br/>not included in the search results.</para>
@@ -1016,9 +1016,10 @@ public SearchRequestDescriptor<TDocument> Indices(Elastic.Clients.Elasticsearch.
1016
1016
private Elastic . Clients . Elasticsearch . Core . Search . Highlight ? HighlightValue { get ; set ; }
1017
1017
private Core . Search . HighlightDescriptor < TDocument > HighlightDescriptor { get ; set ; }
1018
1018
private Action < Core . Search . HighlightDescriptor < TDocument > > HighlightDescriptorAction { get ; set ; }
1019
- private Elastic . Clients . Elasticsearch . KnnQuery ? KnnValue { get ; set ; }
1019
+ private ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? KnnValue { get ; set ; }
1020
1020
private KnnQueryDescriptor < TDocument > KnnDescriptor { get ; set ; }
1021
1021
private Action < KnnQueryDescriptor < TDocument > > KnnDescriptorAction { get ; set ; }
1022
+ private Action < KnnQueryDescriptor < TDocument > > [ ] KnnDescriptorActions { get ; set ; }
1022
1023
private Elastic . Clients . Elasticsearch . QueryDsl . Query ? PostFilterValue { get ; set ; }
1023
1024
private QueryDsl . QueryDescriptor < TDocument > PostFilterDescriptor { get ; set ; }
1024
1025
private Action < QueryDsl . QueryDescriptor < TDocument > > PostFilterDescriptorAction { get ; set ; }
@@ -1215,10 +1216,11 @@ public SearchRequestDescriptor<TDocument> Highlight(Action<Core.Search.Highlight
1215
1216
/// <summary>
1216
1217
/// <para>Defines the approximate kNN search to run.</para>
1217
1218
/// </summary>
1218
- public SearchRequestDescriptor < TDocument > Knn ( Elastic . Clients . Elasticsearch . KnnQuery ? knn )
1219
+ public SearchRequestDescriptor < TDocument > Knn ( ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? knn )
1219
1220
{
1220
1221
KnnDescriptor = null ;
1221
1222
KnnDescriptorAction = null ;
1223
+ KnnDescriptorActions = null ;
1222
1224
KnnValue = knn ;
1223
1225
return Self ;
1224
1226
}
@@ -1227,6 +1229,7 @@ public SearchRequestDescriptor<TDocument> Knn(KnnQueryDescriptor<TDocument> desc
1227
1229
{
1228
1230
KnnValue = null ;
1229
1231
KnnDescriptorAction = null ;
1232
+ KnnDescriptorActions = null ;
1230
1233
KnnDescriptor = descriptor ;
1231
1234
return Self ;
1232
1235
}
@@ -1235,10 +1238,20 @@ public SearchRequestDescriptor<TDocument> Knn(Action<KnnQueryDescriptor<TDocumen
1235
1238
{
1236
1239
KnnValue = null ;
1237
1240
KnnDescriptor = null ;
1241
+ KnnDescriptorActions = null ;
1238
1242
KnnDescriptorAction = configure ;
1239
1243
return Self ;
1240
1244
}
1241
1245
1246
+ public SearchRequestDescriptor < TDocument > Knn ( params Action < KnnQueryDescriptor < TDocument > > [ ] configure )
1247
+ {
1248
+ KnnValue = null ;
1249
+ KnnDescriptor = null ;
1250
+ KnnDescriptorAction = null ;
1251
+ KnnDescriptorActions = configure ;
1252
+ return Self ;
1253
+ }
1254
+
1242
1255
public SearchRequestDescriptor < TDocument > PostFilter ( Elastic . Clients . Elasticsearch . QueryDsl . Query ? postFilter )
1243
1256
{
1244
1257
PostFilterDescriptor = null ;
@@ -1725,10 +1738,23 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
1725
1738
writer . WritePropertyName ( "knn" ) ;
1726
1739
JsonSerializer . Serialize ( writer , new KnnQueryDescriptor < TDocument > ( KnnDescriptorAction ) , options ) ;
1727
1740
}
1741
+ else if ( KnnDescriptorActions is not null )
1742
+ {
1743
+ writer . WritePropertyName ( "knn" ) ;
1744
+ if ( KnnDescriptorActions . Length > 1 )
1745
+ writer . WriteStartArray ( ) ;
1746
+ foreach ( var action in KnnDescriptorActions )
1747
+ {
1748
+ JsonSerializer . Serialize ( writer , new KnnQueryDescriptor < TDocument > ( action ) , options ) ;
1749
+ }
1750
+
1751
+ if ( KnnDescriptorActions . Length > 1 )
1752
+ writer . WriteEndArray ( ) ;
1753
+ }
1728
1754
else if ( KnnValue is not null )
1729
1755
{
1730
1756
writer . WritePropertyName ( "knn" ) ;
1731
- JsonSerializer . Serialize ( writer , KnnValue , options ) ;
1757
+ SingleOrManySerializationHelper . Serialize < Elastic . Clients . Elasticsearch . KnnQuery > ( KnnValue , writer , options ) ;
1732
1758
}
1733
1759
1734
1760
if ( PostFilterDescriptor is not null )
@@ -2061,9 +2087,10 @@ public SearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? in
2061
2087
private Elastic . Clients . Elasticsearch . Core . Search . Highlight ? HighlightValue { get ; set ; }
2062
2088
private Core . Search . HighlightDescriptor HighlightDescriptor { get ; set ; }
2063
2089
private Action < Core . Search . HighlightDescriptor > HighlightDescriptorAction { get ; set ; }
2064
- private Elastic . Clients . Elasticsearch . KnnQuery ? KnnValue { get ; set ; }
2090
+ private ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? KnnValue { get ; set ; }
2065
2091
private KnnQueryDescriptor KnnDescriptor { get ; set ; }
2066
2092
private Action < KnnQueryDescriptor > KnnDescriptorAction { get ; set ; }
2093
+ private Action < KnnQueryDescriptor > [ ] KnnDescriptorActions { get ; set ; }
2067
2094
private Elastic . Clients . Elasticsearch . QueryDsl . Query ? PostFilterValue { get ; set ; }
2068
2095
private QueryDsl . QueryDescriptor PostFilterDescriptor { get ; set ; }
2069
2096
private Action < QueryDsl . QueryDescriptor > PostFilterDescriptorAction { get ; set ; }
@@ -2260,10 +2287,11 @@ public SearchRequestDescriptor Highlight(Action<Core.Search.HighlightDescriptor>
2260
2287
/// <summary>
2261
2288
/// <para>Defines the approximate kNN search to run.</para>
2262
2289
/// </summary>
2263
- public SearchRequestDescriptor Knn ( Elastic . Clients . Elasticsearch . KnnQuery ? knn )
2290
+ public SearchRequestDescriptor Knn ( ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? knn )
2264
2291
{
2265
2292
KnnDescriptor = null ;
2266
2293
KnnDescriptorAction = null ;
2294
+ KnnDescriptorActions = null ;
2267
2295
KnnValue = knn ;
2268
2296
return Self ;
2269
2297
}
@@ -2272,6 +2300,7 @@ public SearchRequestDescriptor Knn(KnnQueryDescriptor descriptor)
2272
2300
{
2273
2301
KnnValue = null ;
2274
2302
KnnDescriptorAction = null ;
2303
+ KnnDescriptorActions = null ;
2275
2304
KnnDescriptor = descriptor ;
2276
2305
return Self ;
2277
2306
}
@@ -2280,10 +2309,20 @@ public SearchRequestDescriptor Knn(Action<KnnQueryDescriptor> configure)
2280
2309
{
2281
2310
KnnValue = null ;
2282
2311
KnnDescriptor = null ;
2312
+ KnnDescriptorActions = null ;
2283
2313
KnnDescriptorAction = configure ;
2284
2314
return Self ;
2285
2315
}
2286
2316
2317
+ public SearchRequestDescriptor Knn ( params Action < KnnQueryDescriptor > [ ] configure )
2318
+ {
2319
+ KnnValue = null ;
2320
+ KnnDescriptor = null ;
2321
+ KnnDescriptorAction = null ;
2322
+ KnnDescriptorActions = configure ;
2323
+ return Self ;
2324
+ }
2325
+
2287
2326
public SearchRequestDescriptor PostFilter ( Elastic . Clients . Elasticsearch . QueryDsl . Query ? postFilter )
2288
2327
{
2289
2328
PostFilterDescriptor = null ;
@@ -2770,10 +2809,23 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
2770
2809
writer . WritePropertyName ( "knn" ) ;
2771
2810
JsonSerializer . Serialize ( writer , new KnnQueryDescriptor ( KnnDescriptorAction ) , options ) ;
2772
2811
}
2812
+ else if ( KnnDescriptorActions is not null )
2813
+ {
2814
+ writer . WritePropertyName ( "knn" ) ;
2815
+ if ( KnnDescriptorActions . Length > 1 )
2816
+ writer . WriteStartArray ( ) ;
2817
+ foreach ( var action in KnnDescriptorActions )
2818
+ {
2819
+ JsonSerializer . Serialize ( writer , new KnnQueryDescriptor ( action ) , options ) ;
2820
+ }
2821
+
2822
+ if ( KnnDescriptorActions . Length > 1 )
2823
+ writer . WriteEndArray ( ) ;
2824
+ }
2773
2825
else if ( KnnValue is not null )
2774
2826
{
2775
2827
writer . WritePropertyName ( "knn" ) ;
2776
- JsonSerializer . Serialize ( writer , KnnValue , options ) ;
2828
+ SingleOrManySerializationHelper . Serialize < Elastic . Clients . Elasticsearch . KnnQuery > ( KnnValue , writer , options ) ;
2777
2829
}
2778
2830
2779
2831
if ( PostFilterDescriptor is not null )
0 commit comments