@@ -240,7 +240,7 @@ public override SubmitAsyncSearchRequest Read(ref Utf8JsonReader reader, Type ty
240
240
241
241
if ( property == "knn" )
242
242
{
243
- variant . Knn = JsonSerializer . Deserialize < Elastic . Clients . Elasticsearch . KnnQuery ? > ( ref reader , options ) ;
243
+ variant . Knn = JsonSerializer . Deserialize < ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? > ( ref reader , options ) ;
244
244
continue ;
245
245
}
246
246
@@ -817,8 +817,8 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices)
817
817
/// <summary>
818
818
/// <para>Defines the approximate kNN search to run.</para>
819
819
/// </summary>
820
- [ JsonInclude , JsonPropertyName ( "knn" ) ]
821
- public Elastic . Clients . Elasticsearch . KnnQuery ? Knn { get ; set ; }
820
+ [ JsonInclude , JsonPropertyName ( "knn" ) , SingleOrManyCollectionConverter ( typeof ( Elastic . Clients . Elasticsearch . KnnQuery ) ) ]
821
+ public ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? Knn { get ; set ; }
822
822
823
823
/// <summary>
824
824
/// <para>Minimum _score for matching documents. Documents with a lower _score are<br/>not included in the search results.</para>
@@ -998,9 +998,10 @@ public SubmitAsyncSearchRequestDescriptor<TDocument> Indices(Elastic.Clients.Ela
998
998
private Elastic . Clients . Elasticsearch . Core . Search . Highlight ? HighlightValue { get ; set ; }
999
999
private Core . Search . HighlightDescriptor < TDocument > HighlightDescriptor { get ; set ; }
1000
1000
private Action < Core . Search . HighlightDescriptor < TDocument > > HighlightDescriptorAction { get ; set ; }
1001
- private Elastic . Clients . Elasticsearch . KnnQuery ? KnnValue { get ; set ; }
1001
+ private ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? KnnValue { get ; set ; }
1002
1002
private KnnQueryDescriptor < TDocument > KnnDescriptor { get ; set ; }
1003
1003
private Action < KnnQueryDescriptor < TDocument > > KnnDescriptorAction { get ; set ; }
1004
+ private Action < KnnQueryDescriptor < TDocument > > [ ] KnnDescriptorActions { get ; set ; }
1004
1005
private Elastic . Clients . Elasticsearch . QueryDsl . Query ? PostFilterValue { get ; set ; }
1005
1006
private QueryDsl . QueryDescriptor < TDocument > PostFilterDescriptor { get ; set ; }
1006
1007
private Action < QueryDsl . QueryDescriptor < TDocument > > PostFilterDescriptorAction { get ; set ; }
@@ -1197,10 +1198,11 @@ public SubmitAsyncSearchRequestDescriptor<TDocument> Highlight(Action<Core.Searc
1197
1198
/// <summary>
1198
1199
/// <para>Defines the approximate kNN search to run.</para>
1199
1200
/// </summary>
1200
- public SubmitAsyncSearchRequestDescriptor < TDocument > Knn ( Elastic . Clients . Elasticsearch . KnnQuery ? knn )
1201
+ public SubmitAsyncSearchRequestDescriptor < TDocument > Knn ( ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? knn )
1201
1202
{
1202
1203
KnnDescriptor = null ;
1203
1204
KnnDescriptorAction = null ;
1205
+ KnnDescriptorActions = null ;
1204
1206
KnnValue = knn ;
1205
1207
return Self ;
1206
1208
}
@@ -1209,6 +1211,7 @@ public SubmitAsyncSearchRequestDescriptor<TDocument> Knn(KnnQueryDescriptor<TDoc
1209
1211
{
1210
1212
KnnValue = null ;
1211
1213
KnnDescriptorAction = null ;
1214
+ KnnDescriptorActions = null ;
1212
1215
KnnDescriptor = descriptor ;
1213
1216
return Self ;
1214
1217
}
@@ -1217,10 +1220,20 @@ public SubmitAsyncSearchRequestDescriptor<TDocument> Knn(Action<KnnQueryDescript
1217
1220
{
1218
1221
KnnValue = null ;
1219
1222
KnnDescriptor = null ;
1223
+ KnnDescriptorActions = null ;
1220
1224
KnnDescriptorAction = configure ;
1221
1225
return Self ;
1222
1226
}
1223
1227
1228
+ public SubmitAsyncSearchRequestDescriptor < TDocument > Knn ( params Action < KnnQueryDescriptor < TDocument > > [ ] configure )
1229
+ {
1230
+ KnnValue = null ;
1231
+ KnnDescriptor = null ;
1232
+ KnnDescriptorAction = null ;
1233
+ KnnDescriptorActions = configure ;
1234
+ return Self ;
1235
+ }
1236
+
1224
1237
public SubmitAsyncSearchRequestDescriptor < TDocument > PostFilter ( Elastic . Clients . Elasticsearch . QueryDsl . Query ? postFilter )
1225
1238
{
1226
1239
PostFilterDescriptor = null ;
@@ -1707,10 +1720,23 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
1707
1720
writer . WritePropertyName ( "knn" ) ;
1708
1721
JsonSerializer . Serialize ( writer , new KnnQueryDescriptor < TDocument > ( KnnDescriptorAction ) , options ) ;
1709
1722
}
1723
+ else if ( KnnDescriptorActions is not null )
1724
+ {
1725
+ writer . WritePropertyName ( "knn" ) ;
1726
+ if ( KnnDescriptorActions . Length > 1 )
1727
+ writer . WriteStartArray ( ) ;
1728
+ foreach ( var action in KnnDescriptorActions )
1729
+ {
1730
+ JsonSerializer . Serialize ( writer , new KnnQueryDescriptor < TDocument > ( action ) , options ) ;
1731
+ }
1732
+
1733
+ if ( KnnDescriptorActions . Length > 1 )
1734
+ writer . WriteEndArray ( ) ;
1735
+ }
1710
1736
else if ( KnnValue is not null )
1711
1737
{
1712
1738
writer . WritePropertyName ( "knn" ) ;
1713
- JsonSerializer . Serialize ( writer , KnnValue , options ) ;
1739
+ SingleOrManySerializationHelper . Serialize < Elastic . Clients . Elasticsearch . KnnQuery > ( KnnValue , writer , options ) ;
1714
1740
}
1715
1741
1716
1742
if ( PostFilterDescriptor is not null )
@@ -2042,9 +2068,10 @@ public SubmitAsyncSearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch.
2042
2068
private Elastic . Clients . Elasticsearch . Core . Search . Highlight ? HighlightValue { get ; set ; }
2043
2069
private Core . Search . HighlightDescriptor HighlightDescriptor { get ; set ; }
2044
2070
private Action < Core . Search . HighlightDescriptor > HighlightDescriptorAction { get ; set ; }
2045
- private Elastic . Clients . Elasticsearch . KnnQuery ? KnnValue { get ; set ; }
2071
+ private ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? KnnValue { get ; set ; }
2046
2072
private KnnQueryDescriptor KnnDescriptor { get ; set ; }
2047
2073
private Action < KnnQueryDescriptor > KnnDescriptorAction { get ; set ; }
2074
+ private Action < KnnQueryDescriptor > [ ] KnnDescriptorActions { get ; set ; }
2048
2075
private Elastic . Clients . Elasticsearch . QueryDsl . Query ? PostFilterValue { get ; set ; }
2049
2076
private QueryDsl . QueryDescriptor PostFilterDescriptor { get ; set ; }
2050
2077
private Action < QueryDsl . QueryDescriptor > PostFilterDescriptorAction { get ; set ; }
@@ -2241,10 +2268,11 @@ public SubmitAsyncSearchRequestDescriptor Highlight(Action<Core.Search.Highlight
2241
2268
/// <summary>
2242
2269
/// <para>Defines the approximate kNN search to run.</para>
2243
2270
/// </summary>
2244
- public SubmitAsyncSearchRequestDescriptor Knn ( Elastic . Clients . Elasticsearch . KnnQuery ? knn )
2271
+ public SubmitAsyncSearchRequestDescriptor Knn ( ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? knn )
2245
2272
{
2246
2273
KnnDescriptor = null ;
2247
2274
KnnDescriptorAction = null ;
2275
+ KnnDescriptorActions = null ;
2248
2276
KnnValue = knn ;
2249
2277
return Self ;
2250
2278
}
@@ -2253,6 +2281,7 @@ public SubmitAsyncSearchRequestDescriptor Knn(KnnQueryDescriptor descriptor)
2253
2281
{
2254
2282
KnnValue = null ;
2255
2283
KnnDescriptorAction = null ;
2284
+ KnnDescriptorActions = null ;
2256
2285
KnnDescriptor = descriptor ;
2257
2286
return Self ;
2258
2287
}
@@ -2261,10 +2290,20 @@ public SubmitAsyncSearchRequestDescriptor Knn(Action<KnnQueryDescriptor> configu
2261
2290
{
2262
2291
KnnValue = null ;
2263
2292
KnnDescriptor = null ;
2293
+ KnnDescriptorActions = null ;
2264
2294
KnnDescriptorAction = configure ;
2265
2295
return Self ;
2266
2296
}
2267
2297
2298
+ public SubmitAsyncSearchRequestDescriptor Knn ( params Action < KnnQueryDescriptor > [ ] configure )
2299
+ {
2300
+ KnnValue = null ;
2301
+ KnnDescriptor = null ;
2302
+ KnnDescriptorAction = null ;
2303
+ KnnDescriptorActions = configure ;
2304
+ return Self ;
2305
+ }
2306
+
2268
2307
public SubmitAsyncSearchRequestDescriptor PostFilter ( Elastic . Clients . Elasticsearch . QueryDsl . Query ? postFilter )
2269
2308
{
2270
2309
PostFilterDescriptor = null ;
@@ -2751,10 +2790,23 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
2751
2790
writer . WritePropertyName ( "knn" ) ;
2752
2791
JsonSerializer . Serialize ( writer , new KnnQueryDescriptor ( KnnDescriptorAction ) , options ) ;
2753
2792
}
2793
+ else if ( KnnDescriptorActions is not null )
2794
+ {
2795
+ writer . WritePropertyName ( "knn" ) ;
2796
+ if ( KnnDescriptorActions . Length > 1 )
2797
+ writer . WriteStartArray ( ) ;
2798
+ foreach ( var action in KnnDescriptorActions )
2799
+ {
2800
+ JsonSerializer . Serialize ( writer , new KnnQueryDescriptor ( action ) , options ) ;
2801
+ }
2802
+
2803
+ if ( KnnDescriptorActions . Length > 1 )
2804
+ writer . WriteEndArray ( ) ;
2805
+ }
2754
2806
else if ( KnnValue is not null )
2755
2807
{
2756
2808
writer . WritePropertyName ( "knn" ) ;
2757
- JsonSerializer . Serialize ( writer , KnnValue , options ) ;
2809
+ SingleOrManySerializationHelper . Serialize < Elastic . Clients . Elasticsearch . KnnQuery > ( KnnValue , writer , options ) ;
2758
2810
}
2759
2811
2760
2812
if ( PostFilterDescriptor is not null )
0 commit comments