@@ -38,13 +38,8 @@ public sealed partial class CompletionSuggester
3838
3939 [ JsonInclude , JsonPropertyName ( "fuzzy" ) ]
4040 public Elastic . Clients . Elasticsearch . Core . Search . SuggestFuzziness ? Fuzzy { get ; set ; }
41-
42- [ JsonInclude , JsonPropertyName ( "prefix" ) ]
43- public string ? Prefix { get ; set ; }
44-
4541 [ JsonInclude , JsonPropertyName ( "regex" ) ]
46- public string ? Regex { get ; set ; }
47-
42+ public Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? Regex { get ; set ; }
4843 [ JsonInclude , JsonPropertyName ( "size" ) ]
4944 public int ? Size { get ; set ; }
5045
@@ -72,11 +67,9 @@ public CompletionSuggesterDescriptor() : base()
7267 private SuggestFuzzinessDescriptor FuzzyDescriptor { get ; set ; }
7368
7469 private Action < SuggestFuzzinessDescriptor > FuzzyDescriptorAction { get ; set ; }
75-
76- private string ? PrefixValue { get ; set ; }
77-
78- private string ? RegexValue { get ; set ; }
79-
70+ private Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? RegexValue { get ; set ; }
71+ private RegexOptionsDescriptor RegexDescriptor { get ; set ; }
72+ private Action < RegexOptionsDescriptor > RegexDescriptorAction { get ; set ; }
8073 private int ? SizeValue { get ; set ; }
8174
8275 private bool ? SkipDuplicatesValue { get ; set ; }
@@ -129,15 +122,27 @@ public CompletionSuggesterDescriptor<TDocument> Fuzzy(Action<SuggestFuzzinessDes
129122 return Self ;
130123 }
131124
132- public CompletionSuggesterDescriptor < TDocument > Prefix ( string ? prefix )
125+ public CompletionSuggesterDescriptor < TDocument > Regex ( Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? regex )
133126 {
134- PrefixValue = prefix ;
127+ RegexDescriptor = null ;
128+ RegexDescriptorAction = null ;
129+ RegexValue = regex ;
135130 return Self ;
136131 }
137132
138- public CompletionSuggesterDescriptor < TDocument > Regex ( string ? regex )
133+ public CompletionSuggesterDescriptor < TDocument > Regex ( RegexOptionsDescriptor descriptor )
139134 {
140- RegexValue = regex ;
135+ RegexValue = null ;
136+ RegexDescriptorAction = null ;
137+ RegexDescriptor = descriptor ;
138+ return Self ;
139+ }
140+
141+ public CompletionSuggesterDescriptor < TDocument > Regex ( Action < RegexOptionsDescriptor > configure )
142+ {
143+ RegexValue = null ;
144+ RegexDescriptor = null ;
145+ RegexDescriptorAction = configure ;
141146 return Self ;
142147 }
143148
@@ -186,16 +191,20 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
186191 JsonSerializer . Serialize ( writer , FuzzyValue , options ) ;
187192 }
188193
189- if ( ! string . IsNullOrEmpty ( PrefixValue ) )
194+ if ( RegexDescriptor is not null )
190195 {
191- writer . WritePropertyName ( "prefix " ) ;
192- writer . WriteStringValue ( PrefixValue ) ;
196+ writer . WritePropertyName ( "regex " ) ;
197+ JsonSerializer . Serialize ( writer , RegexDescriptor , options ) ;
193198 }
194-
195- if ( ! string . IsNullOrEmpty ( RegexValue ) )
199+ else if ( RegexDescriptorAction is not null )
196200 {
197201 writer . WritePropertyName ( "regex" ) ;
198- writer . WriteStringValue ( RegexValue ) ;
202+ JsonSerializer . Serialize ( writer , new RegexOptionsDescriptor ( RegexDescriptorAction ) , options ) ;
203+ }
204+ else if ( RegexValue is not null )
205+ {
206+ writer . WritePropertyName ( "regex" ) ;
207+ JsonSerializer . Serialize ( writer , RegexValue , options ) ;
199208 }
200209
201210 if ( SizeValue . HasValue )
@@ -232,11 +241,9 @@ public CompletionSuggesterDescriptor() : base()
232241 private SuggestFuzzinessDescriptor FuzzyDescriptor { get ; set ; }
233242
234243 private Action < SuggestFuzzinessDescriptor > FuzzyDescriptorAction { get ; set ; }
235-
236- private string ? PrefixValue { get ; set ; }
237-
238- private string ? RegexValue { get ; set ; }
239-
244+ private Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? RegexValue { get ; set ; }
245+ private RegexOptionsDescriptor RegexDescriptor { get ; set ; }
246+ private Action < RegexOptionsDescriptor > RegexDescriptorAction { get ; set ; }
240247 private int ? SizeValue { get ; set ; }
241248
242249 private bool ? SkipDuplicatesValue { get ; set ; }
@@ -295,15 +302,27 @@ public CompletionSuggesterDescriptor Fuzzy(Action<SuggestFuzzinessDescriptor> co
295302 return Self ;
296303 }
297304
298- public CompletionSuggesterDescriptor Prefix ( string ? prefix )
305+ public CompletionSuggesterDescriptor Regex ( Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? regex )
299306 {
300- PrefixValue = prefix ;
307+ RegexDescriptor = null ;
308+ RegexDescriptorAction = null ;
309+ RegexValue = regex ;
301310 return Self ;
302311 }
303312
304- public CompletionSuggesterDescriptor Regex ( string ? regex )
313+ public CompletionSuggesterDescriptor Regex ( RegexOptionsDescriptor descriptor )
305314 {
306- RegexValue = regex ;
315+ RegexValue = null ;
316+ RegexDescriptorAction = null ;
317+ RegexDescriptor = descriptor ;
318+ return Self ;
319+ }
320+
321+ public CompletionSuggesterDescriptor Regex ( Action < RegexOptionsDescriptor > configure )
322+ {
323+ RegexValue = null ;
324+ RegexDescriptor = null ;
325+ RegexDescriptorAction = configure ;
307326 return Self ;
308327 }
309328
@@ -352,16 +371,20 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
352371 JsonSerializer . Serialize ( writer , FuzzyValue , options ) ;
353372 }
354373
355- if ( ! string . IsNullOrEmpty ( PrefixValue ) )
374+ if ( RegexDescriptor is not null )
356375 {
357- writer . WritePropertyName ( "prefix " ) ;
358- writer . WriteStringValue ( PrefixValue ) ;
376+ writer . WritePropertyName ( "regex " ) ;
377+ JsonSerializer . Serialize ( writer , RegexDescriptor , options ) ;
359378 }
360-
361- if ( ! string . IsNullOrEmpty ( RegexValue ) )
379+ else if ( RegexDescriptorAction is not null )
380+ {
381+ writer . WritePropertyName ( "regex" ) ;
382+ JsonSerializer . Serialize ( writer , new RegexOptionsDescriptor ( RegexDescriptorAction ) , options ) ;
383+ }
384+ else if ( RegexValue is not null )
362385 {
363386 writer . WritePropertyName ( "regex" ) ;
364- writer . WriteStringValue ( RegexValue ) ;
387+ JsonSerializer . Serialize ( writer , RegexValue , options ) ;
365388 }
366389
367390 if ( SizeValue . HasValue )
0 commit comments