@@ -73,6 +73,7 @@ internal Query(string variantName, object variant)
73
73
public static Query QueryString ( Elastic . Clients . Elasticsearch . QueryDsl . QueryStringQuery queryStringQuery ) => new Query ( "query_string" , queryStringQuery ) ;
74
74
public static Query Range ( Elastic . Clients . Elasticsearch . QueryDsl . RangeQuery rangeQuery ) => new Query ( "range" , rangeQuery ) ;
75
75
public static Query RankFeature ( Elastic . Clients . Elasticsearch . QueryDsl . RankFeatureQuery rankFeatureQuery ) => new Query ( "rank_feature" , rankFeatureQuery ) ;
76
+ public static Query RawJson ( Elastic . Clients . Elasticsearch . QueryDsl . RawJsonQuery rawJsonQuery ) => new Query ( "raw_json" , rawJsonQuery ) ;
76
77
public static Query Regexp ( Elastic . Clients . Elasticsearch . QueryDsl . RegexpQuery regexpQuery ) => new Query ( "regexp" , regexpQuery ) ;
77
78
public static Query Script ( Elastic . Clients . Elasticsearch . QueryDsl . ScriptQuery scriptQuery ) => new Query ( "script" , scriptQuery ) ;
78
79
public static Query ScriptScore ( Elastic . Clients . Elasticsearch . QueryDsl . ScriptScoreQuery scriptScoreQuery ) => new Query ( "script_score" , scriptScoreQuery ) ;
@@ -312,6 +313,13 @@ public override Query Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSe
312
313
return new Query ( propertyName , variant ) ;
313
314
}
314
315
316
+ if ( propertyName == "raw_json" )
317
+ {
318
+ var variant = JsonSerializer . Deserialize < Elastic . Clients . Elasticsearch . QueryDsl . RawJsonQuery ? > ( ref reader , options ) ;
319
+ reader . Read ( ) ;
320
+ return new Query ( propertyName , variant ) ;
321
+ }
322
+
315
323
if ( propertyName == "regexp" )
316
324
{
317
325
var variant = JsonSerializer . Deserialize < Elastic . Clients . Elasticsearch . QueryDsl . RegexpQuery ? > ( ref reader , options ) ;
@@ -436,6 +444,12 @@ public override Query Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSe
436
444
437
445
public override void Write ( Utf8JsonWriter writer , Query value , JsonSerializerOptions options )
438
446
{
447
+ if ( value . VariantName == "raw_json" && value . TryGet < RawJsonQuery > ( out var rawJsonQuery ) )
448
+ {
449
+ writer . WriteRawValue ( rawJsonQuery . Raw ) ;
450
+ return ;
451
+ }
452
+
439
453
writer . WriteStartObject ( ) ;
440
454
writer . WritePropertyName ( value . VariantName ) ;
441
455
switch ( value . VariantName )
@@ -527,6 +541,9 @@ public override void Write(Utf8JsonWriter writer, Query value, JsonSerializerOpt
527
541
case "rank_feature" :
528
542
JsonSerializer . Serialize < Elastic . Clients . Elasticsearch . QueryDsl . RankFeatureQuery > ( writer , ( Elastic . Clients . Elasticsearch . QueryDsl . RankFeatureQuery ) value . Variant , options ) ;
529
543
break ;
544
+ case "raw_json" :
545
+ JsonSerializer . Serialize < Elastic . Clients . Elasticsearch . QueryDsl . RawJsonQuery > ( writer , ( Elastic . Clients . Elasticsearch . QueryDsl . RawJsonQuery ) value . Variant , options ) ;
546
+ break ;
530
547
case "regexp" :
531
548
JsonSerializer . Serialize < Elastic . Clients . Elasticsearch . QueryDsl . RegexpQuery > ( writer , ( Elastic . Clients . Elasticsearch . QueryDsl . RegexpQuery ) value . Variant , options ) ;
532
549
break ;
@@ -676,6 +693,7 @@ private QueryDescriptor<TDocument> Set(object variant, string variantName)
676
693
public QueryDescriptor < TDocument > Range ( Action < RangeQueryDescriptor < TDocument > > configure ) => Set ( configure , "range" ) ;
677
694
public QueryDescriptor < TDocument > RankFeature ( RankFeatureQuery rankFeatureQuery ) => Set ( rankFeatureQuery , "rank_feature" ) ;
678
695
public QueryDescriptor < TDocument > RankFeature ( Action < RankFeatureQueryDescriptor < TDocument > > configure ) => Set ( configure , "rank_feature" ) ;
696
+ public QueryDescriptor < TDocument > RawJson ( Elastic . Clients . Elasticsearch . QueryDsl . RawJsonQuery rawJsonQuery ) => Set ( rawJsonQuery , "raw_json" ) ;
679
697
public QueryDescriptor < TDocument > Regexp ( RegexpQuery regexpQuery ) => Set ( regexpQuery , "regexp" ) ;
680
698
public QueryDescriptor < TDocument > Regexp ( Action < RegexpQueryDescriptor < TDocument > > configure ) => Set ( configure , "regexp" ) ;
681
699
public QueryDescriptor < TDocument > Script ( ScriptQuery scriptQuery ) => Set ( scriptQuery , "script" ) ;
@@ -718,6 +736,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
718
736
return ;
719
737
}
720
738
739
+ if ( ContainedVariantName == "raw_json" )
740
+ {
741
+ writer . WriteRawValue ( ( ( RawJsonQuery ) Variant ) . Raw ) ;
742
+ return ;
743
+ }
744
+
721
745
writer . WriteStartObject ( ) ;
722
746
writer . WritePropertyName ( ContainedVariantName ) ;
723
747
if ( Variant is not null )
@@ -849,6 +873,7 @@ private QueryDescriptor Set(object variant, string variantName)
849
873
public QueryDescriptor RankFeature ( RankFeatureQuery rankFeatureQuery ) => Set ( rankFeatureQuery , "rank_feature" ) ;
850
874
public QueryDescriptor RankFeature ( Action < RankFeatureQueryDescriptor > configure ) => Set ( configure , "rank_feature" ) ;
851
875
public QueryDescriptor RankFeature < TDocument > ( Action < RankFeatureQueryDescriptor < TDocument > > configure ) => Set ( configure , "rank_feature" ) ;
876
+ public QueryDescriptor RawJson ( Elastic . Clients . Elasticsearch . QueryDsl . RawJsonQuery rawJsonQuery ) => Set ( rawJsonQuery , "raw_json" ) ;
852
877
public QueryDescriptor Regexp ( RegexpQuery regexpQuery ) => Set ( regexpQuery , "regexp" ) ;
853
878
public QueryDescriptor Regexp ( Action < RegexpQueryDescriptor > configure ) => Set ( configure , "regexp" ) ;
854
879
public QueryDescriptor Regexp < TDocument > ( Action < RegexpQueryDescriptor < TDocument > > configure ) => Set ( configure , "regexp" ) ;
@@ -906,6 +931,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
906
931
return ;
907
932
}
908
933
934
+ if ( ContainedVariantName == "raw_json" )
935
+ {
936
+ writer . WriteRawValue ( ( ( RawJsonQuery ) Variant ) . Raw ) ;
937
+ return ;
938
+ }
939
+
909
940
writer . WriteStartObject ( ) ;
910
941
writer . WritePropertyName ( ContainedVariantName ) ;
911
942
if ( Variant is not null )
0 commit comments