@@ -245,7 +245,7 @@ public override SearchRequest Read(ref Utf8JsonReader reader, Type typeToConvert
245245
246246 if ( property == "knn" )
247247 {
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 ) ;
249249 continue ;
250250 }
251251
@@ -824,8 +824,8 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r =>
824824 /// <summary>
825825 /// <para>Defines the approximate kNN search to run.</para>
826826 /// </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 ; }
829829
830830 /// <summary>
831831 /// <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.
10161016 private Elastic . Clients . Elasticsearch . Core . Search . Highlight ? HighlightValue { get ; set ; }
10171017 private Core . Search . HighlightDescriptor < TDocument > HighlightDescriptor { get ; set ; }
10181018 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 ; }
10201020 private KnnQueryDescriptor < TDocument > KnnDescriptor { get ; set ; }
10211021 private Action < KnnQueryDescriptor < TDocument > > KnnDescriptorAction { get ; set ; }
1022+ private Action < KnnQueryDescriptor < TDocument > > [ ] KnnDescriptorActions { get ; set ; }
10221023 private Elastic . Clients . Elasticsearch . QueryDsl . Query ? PostFilterValue { get ; set ; }
10231024 private QueryDsl . QueryDescriptor < TDocument > PostFilterDescriptor { get ; set ; }
10241025 private Action < QueryDsl . QueryDescriptor < TDocument > > PostFilterDescriptorAction { get ; set ; }
@@ -1215,10 +1216,11 @@ public SearchRequestDescriptor<TDocument> Highlight(Action<Core.Search.Highlight
12151216 /// <summary>
12161217 /// <para>Defines the approximate kNN search to run.</para>
12171218 /// </summary>
1218- public SearchRequestDescriptor < TDocument > Knn ( Elastic . Clients . Elasticsearch . KnnQuery ? knn )
1219+ public SearchRequestDescriptor < TDocument > Knn ( ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? knn )
12191220 {
12201221 KnnDescriptor = null ;
12211222 KnnDescriptorAction = null ;
1223+ KnnDescriptorActions = null ;
12221224 KnnValue = knn ;
12231225 return Self ;
12241226 }
@@ -1227,6 +1229,7 @@ public SearchRequestDescriptor<TDocument> Knn(KnnQueryDescriptor<TDocument> desc
12271229 {
12281230 KnnValue = null ;
12291231 KnnDescriptorAction = null ;
1232+ KnnDescriptorActions = null ;
12301233 KnnDescriptor = descriptor ;
12311234 return Self ;
12321235 }
@@ -1235,10 +1238,20 @@ public SearchRequestDescriptor<TDocument> Knn(Action<KnnQueryDescriptor<TDocumen
12351238 {
12361239 KnnValue = null ;
12371240 KnnDescriptor = null ;
1241+ KnnDescriptorActions = null ;
12381242 KnnDescriptorAction = configure ;
12391243 return Self ;
12401244 }
12411245
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+
12421255 public SearchRequestDescriptor < TDocument > PostFilter ( Elastic . Clients . Elasticsearch . QueryDsl . Query ? postFilter )
12431256 {
12441257 PostFilterDescriptor = null ;
@@ -1725,10 +1738,23 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
17251738 writer . WritePropertyName ( "knn" ) ;
17261739 JsonSerializer . Serialize ( writer , new KnnQueryDescriptor < TDocument > ( KnnDescriptorAction ) , options ) ;
17271740 }
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+ }
17281754 else if ( KnnValue is not null )
17291755 {
17301756 writer . WritePropertyName ( "knn" ) ;
1731- JsonSerializer . Serialize ( writer , KnnValue , options ) ;
1757+ SingleOrManySerializationHelper . Serialize < Elastic . Clients . Elasticsearch . KnnQuery > ( KnnValue , writer , options ) ;
17321758 }
17331759
17341760 if ( PostFilterDescriptor is not null )
@@ -2061,9 +2087,10 @@ public SearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? in
20612087 private Elastic . Clients . Elasticsearch . Core . Search . Highlight ? HighlightValue { get ; set ; }
20622088 private Core . Search . HighlightDescriptor HighlightDescriptor { get ; set ; }
20632089 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 ; }
20652091 private KnnQueryDescriptor KnnDescriptor { get ; set ; }
20662092 private Action < KnnQueryDescriptor > KnnDescriptorAction { get ; set ; }
2093+ private Action < KnnQueryDescriptor > [ ] KnnDescriptorActions { get ; set ; }
20672094 private Elastic . Clients . Elasticsearch . QueryDsl . Query ? PostFilterValue { get ; set ; }
20682095 private QueryDsl . QueryDescriptor PostFilterDescriptor { get ; set ; }
20692096 private Action < QueryDsl . QueryDescriptor > PostFilterDescriptorAction { get ; set ; }
@@ -2260,10 +2287,11 @@ public SearchRequestDescriptor Highlight(Action<Core.Search.HighlightDescriptor>
22602287 /// <summary>
22612288 /// <para>Defines the approximate kNN search to run.</para>
22622289 /// </summary>
2263- public SearchRequestDescriptor Knn ( Elastic . Clients . Elasticsearch . KnnQuery ? knn )
2290+ public SearchRequestDescriptor Knn ( ICollection < Elastic . Clients . Elasticsearch . KnnQuery > ? knn )
22642291 {
22652292 KnnDescriptor = null ;
22662293 KnnDescriptorAction = null ;
2294+ KnnDescriptorActions = null ;
22672295 KnnValue = knn ;
22682296 return Self ;
22692297 }
@@ -2272,6 +2300,7 @@ public SearchRequestDescriptor Knn(KnnQueryDescriptor descriptor)
22722300 {
22732301 KnnValue = null ;
22742302 KnnDescriptorAction = null ;
2303+ KnnDescriptorActions = null ;
22752304 KnnDescriptor = descriptor ;
22762305 return Self ;
22772306 }
@@ -2280,10 +2309,20 @@ public SearchRequestDescriptor Knn(Action<KnnQueryDescriptor> configure)
22802309 {
22812310 KnnValue = null ;
22822311 KnnDescriptor = null ;
2312+ KnnDescriptorActions = null ;
22832313 KnnDescriptorAction = configure ;
22842314 return Self ;
22852315 }
22862316
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+
22872326 public SearchRequestDescriptor PostFilter ( Elastic . Clients . Elasticsearch . QueryDsl . Query ? postFilter )
22882327 {
22892328 PostFilterDescriptor = null ;
@@ -2770,10 +2809,23 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
27702809 writer . WritePropertyName ( "knn" ) ;
27712810 JsonSerializer . Serialize ( writer , new KnnQueryDescriptor ( KnnDescriptorAction ) , options ) ;
27722811 }
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+ }
27732825 else if ( KnnValue is not null )
27742826 {
27752827 writer . WritePropertyName ( "knn" ) ;
2776- JsonSerializer . Serialize ( writer , KnnValue , options ) ;
2828+ SingleOrManySerializationHelper . Serialize < Elastic . Clients . Elasticsearch . KnnQuery > ( KnnValue , writer , options ) ;
27772829 }
27782830
27792831 if ( PostFilterDescriptor is not null )
0 commit comments