@@ -240,7 +240,7 @@ public override SubmitAsyncSearchRequest Read(ref Utf8JsonReader reader, Type ty
240240
241241 if ( property == "knn" )
242242 {
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 ) ;
244244 continue ;
245245 }
246246
@@ -817,8 +817,8 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices)
817817 /// <summary>
818818 /// <para>Defines the approximate kNN search to run.</para>
819819 /// </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 ; }
822822
823823 /// <summary>
824824 /// <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
998998 private Elastic . Clients . Elasticsearch . Core . Search . Highlight ? HighlightValue { get ; set ; }
999999 private Core . Search . HighlightDescriptor < TDocument > HighlightDescriptor { get ; set ; }
10001000 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 ; }
10021002 private KnnQueryDescriptor < TDocument > KnnDescriptor { get ; set ; }
10031003 private Action < KnnQueryDescriptor < TDocument > > KnnDescriptorAction { get ; set ; }
1004+ private Action < KnnQueryDescriptor < TDocument > > [ ] KnnDescriptorActions { get ; set ; }
10041005 private Elastic . Clients . Elasticsearch . QueryDsl . Query ? PostFilterValue { get ; set ; }
10051006 private QueryDsl . QueryDescriptor < TDocument > PostFilterDescriptor { get ; set ; }
10061007 private Action < QueryDsl . QueryDescriptor < TDocument > > PostFilterDescriptorAction { get ; set ; }
@@ -1197,10 +1198,11 @@ public SubmitAsyncSearchRequestDescriptor<TDocument> Highlight(Action<Core.Searc
11971198 /// <summary>
11981199 /// <para>Defines the approximate kNN search to run.</para>
11991200 /// </summary>
1200- public SubmitAsyncSearchRequestDescriptor < TDocument > Knn ( Elastic . Clients . Elasticsearch . KnnQuery ? knn )
1201+ public SubmitAsyncSearchRequestDescriptor < TDocument > Knn ( ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? knn )
12011202 {
12021203 KnnDescriptor = null ;
12031204 KnnDescriptorAction = null ;
1205+ KnnDescriptorActions = null ;
12041206 KnnValue = knn ;
12051207 return Self ;
12061208 }
@@ -1209,6 +1211,7 @@ public SubmitAsyncSearchRequestDescriptor<TDocument> Knn(KnnQueryDescriptor<TDoc
12091211 {
12101212 KnnValue = null ;
12111213 KnnDescriptorAction = null ;
1214+ KnnDescriptorActions = null ;
12121215 KnnDescriptor = descriptor ;
12131216 return Self ;
12141217 }
@@ -1217,10 +1220,20 @@ public SubmitAsyncSearchRequestDescriptor<TDocument> Knn(Action<KnnQueryDescript
12171220 {
12181221 KnnValue = null ;
12191222 KnnDescriptor = null ;
1223+ KnnDescriptorActions = null ;
12201224 KnnDescriptorAction = configure ;
12211225 return Self ;
12221226 }
12231227
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+
12241237 public SubmitAsyncSearchRequestDescriptor < TDocument > PostFilter ( Elastic . Clients . Elasticsearch . QueryDsl . Query ? postFilter )
12251238 {
12261239 PostFilterDescriptor = null ;
@@ -1707,10 +1720,23 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
17071720 writer . WritePropertyName ( "knn" ) ;
17081721 JsonSerializer . Serialize ( writer , new KnnQueryDescriptor < TDocument > ( KnnDescriptorAction ) , options ) ;
17091722 }
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+ }
17101736 else if ( KnnValue is not null )
17111737 {
17121738 writer . WritePropertyName ( "knn" ) ;
1713- JsonSerializer . Serialize ( writer , KnnValue , options ) ;
1739+ SingleOrManySerializationHelper . Serialize < Elastic . Clients . Elasticsearch . KnnQuery > ( KnnValue , writer , options ) ;
17141740 }
17151741
17161742 if ( PostFilterDescriptor is not null )
@@ -2042,9 +2068,10 @@ public SubmitAsyncSearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch.
20422068 private Elastic . Clients . Elasticsearch . Core . Search . Highlight ? HighlightValue { get ; set ; }
20432069 private Core . Search . HighlightDescriptor HighlightDescriptor { get ; set ; }
20442070 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 ; }
20462072 private KnnQueryDescriptor KnnDescriptor { get ; set ; }
20472073 private Action < KnnQueryDescriptor > KnnDescriptorAction { get ; set ; }
2074+ private Action < KnnQueryDescriptor > [ ] KnnDescriptorActions { get ; set ; }
20482075 private Elastic . Clients . Elasticsearch . QueryDsl . Query ? PostFilterValue { get ; set ; }
20492076 private QueryDsl . QueryDescriptor PostFilterDescriptor { get ; set ; }
20502077 private Action < QueryDsl . QueryDescriptor > PostFilterDescriptorAction { get ; set ; }
@@ -2241,10 +2268,11 @@ public SubmitAsyncSearchRequestDescriptor Highlight(Action<Core.Search.Highlight
22412268 /// <summary>
22422269 /// <para>Defines the approximate kNN search to run.</para>
22432270 /// </summary>
2244- public SubmitAsyncSearchRequestDescriptor Knn ( Elastic . Clients . Elasticsearch . KnnQuery ? knn )
2271+ public SubmitAsyncSearchRequestDescriptor Knn ( ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? knn )
22452272 {
22462273 KnnDescriptor = null ;
22472274 KnnDescriptorAction = null ;
2275+ KnnDescriptorActions = null ;
22482276 KnnValue = knn ;
22492277 return Self ;
22502278 }
@@ -2253,6 +2281,7 @@ public SubmitAsyncSearchRequestDescriptor Knn(KnnQueryDescriptor descriptor)
22532281 {
22542282 KnnValue = null ;
22552283 KnnDescriptorAction = null ;
2284+ KnnDescriptorActions = null ;
22562285 KnnDescriptor = descriptor ;
22572286 return Self ;
22582287 }
@@ -2261,10 +2290,20 @@ public SubmitAsyncSearchRequestDescriptor Knn(Action<KnnQueryDescriptor> configu
22612290 {
22622291 KnnValue = null ;
22632292 KnnDescriptor = null ;
2293+ KnnDescriptorActions = null ;
22642294 KnnDescriptorAction = configure ;
22652295 return Self ;
22662296 }
22672297
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+
22682307 public SubmitAsyncSearchRequestDescriptor PostFilter ( Elastic . Clients . Elasticsearch . QueryDsl . Query ? postFilter )
22692308 {
22702309 PostFilterDescriptor = null ;
@@ -2751,10 +2790,23 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
27512790 writer . WritePropertyName ( "knn" ) ;
27522791 JsonSerializer . Serialize ( writer , new KnnQueryDescriptor ( KnnDescriptorAction ) , options ) ;
27532792 }
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+ }
27542806 else if ( KnnValue is not null )
27552807 {
27562808 writer . WritePropertyName ( "knn" ) ;
2757- JsonSerializer . Serialize ( writer , KnnValue , options ) ;
2809+ SingleOrManySerializationHelper . Serialize < Elastic . Clients . Elasticsearch . KnnQuery > ( KnnValue , writer , options ) ;
27582810 }
27592811
27602812 if ( PostFilterDescriptor is not null )
0 commit comments