@@ -37,10 +37,8 @@ public sealed partial class CompletionSuggester
3737 public Elastic . Clients . Elasticsearch . Field Field { get ; set ; }
3838 [ JsonInclude , JsonPropertyName ( "fuzzy" ) ]
3939 public Elastic . Clients . Elasticsearch . Core . Search . SuggestFuzziness ? Fuzzy { get ; set ; }
40- [ JsonInclude , JsonPropertyName ( "prefix" ) ]
41- public string ? Prefix { get ; set ; }
4240 [ JsonInclude , JsonPropertyName ( "regex" ) ]
43- public string ? Regex { get ; set ; }
41+ public Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? Regex { get ; set ; }
4442 [ JsonInclude , JsonPropertyName ( "size" ) ]
4543 public int ? Size { get ; set ; }
4644 [ JsonInclude , JsonPropertyName ( "skip_duplicates" ) ]
@@ -63,8 +61,9 @@ public CompletionSuggesterDescriptor() : base()
6361 private Elastic . Clients . Elasticsearch . Core . Search . SuggestFuzziness ? FuzzyValue { get ; set ; }
6462 private SuggestFuzzinessDescriptor FuzzyDescriptor { get ; set ; }
6563 private Action < SuggestFuzzinessDescriptor > FuzzyDescriptorAction { get ; set ; }
66- private string ? PrefixValue { get ; set ; }
67- private string ? RegexValue { get ; set ; }
64+ private Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? RegexValue { get ; set ; }
65+ private RegexOptionsDescriptor RegexDescriptor { get ; set ; }
66+ private Action < RegexOptionsDescriptor > RegexDescriptorAction { get ; set ; }
6867 private int ? SizeValue { get ; set ; }
6968 private bool ? SkipDuplicatesValue { get ; set ; }
7069
@@ -116,15 +115,27 @@ public CompletionSuggesterDescriptor<TDocument> Fuzzy(Action<SuggestFuzzinessDes
116115 return Self ;
117116 }
118117
119- public CompletionSuggesterDescriptor < TDocument > Prefix ( string ? prefix )
118+ public CompletionSuggesterDescriptor < TDocument > Regex ( Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? regex )
120119 {
121- PrefixValue = prefix ;
120+ RegexDescriptor = null ;
121+ RegexDescriptorAction = null ;
122+ RegexValue = regex ;
122123 return Self ;
123124 }
124125
125- public CompletionSuggesterDescriptor < TDocument > Regex ( string ? regex )
126+ public CompletionSuggesterDescriptor < TDocument > Regex ( RegexOptionsDescriptor descriptor )
126127 {
127- RegexValue = regex ;
128+ RegexValue = null ;
129+ RegexDescriptorAction = null ;
130+ RegexDescriptor = descriptor ;
131+ return Self ;
132+ }
133+
134+ public CompletionSuggesterDescriptor < TDocument > Regex ( Action < RegexOptionsDescriptor > configure )
135+ {
136+ RegexValue = null ;
137+ RegexDescriptor = null ;
138+ RegexDescriptorAction = configure ;
128139 return Self ;
129140 }
130141
@@ -173,16 +184,20 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
173184 JsonSerializer . Serialize ( writer , FuzzyValue , options ) ;
174185 }
175186
176- if ( ! string . IsNullOrEmpty ( PrefixValue ) )
187+ if ( RegexDescriptor is not null )
177188 {
178- writer . WritePropertyName ( "prefix " ) ;
179- writer . WriteStringValue ( PrefixValue ) ;
189+ writer . WritePropertyName ( "regex " ) ;
190+ JsonSerializer . Serialize ( writer , RegexDescriptor , options ) ;
180191 }
181-
182- if ( ! string . IsNullOrEmpty ( RegexValue ) )
192+ else if ( RegexDescriptorAction is not null )
193+ {
194+ writer . WritePropertyName ( "regex" ) ;
195+ JsonSerializer . Serialize ( writer , new RegexOptionsDescriptor ( RegexDescriptorAction ) , options ) ;
196+ }
197+ else if ( RegexValue is not null )
183198 {
184199 writer . WritePropertyName ( "regex" ) ;
185- writer . WriteStringValue ( RegexValue ) ;
200+ JsonSerializer . Serialize ( writer , RegexValue , options ) ;
186201 }
187202
188203 if ( SizeValue . HasValue )
@@ -215,8 +230,9 @@ public CompletionSuggesterDescriptor() : base()
215230 private Elastic . Clients . Elasticsearch . Core . Search . SuggestFuzziness ? FuzzyValue { get ; set ; }
216231 private SuggestFuzzinessDescriptor FuzzyDescriptor { get ; set ; }
217232 private Action < SuggestFuzzinessDescriptor > FuzzyDescriptorAction { get ; set ; }
218- private string ? PrefixValue { get ; set ; }
219- private string ? RegexValue { get ; set ; }
233+ private Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? RegexValue { get ; set ; }
234+ private RegexOptionsDescriptor RegexDescriptor { get ; set ; }
235+ private Action < RegexOptionsDescriptor > RegexDescriptorAction { get ; set ; }
220236 private int ? SizeValue { get ; set ; }
221237 private bool ? SkipDuplicatesValue { get ; set ; }
222238
@@ -274,15 +290,27 @@ public CompletionSuggesterDescriptor Fuzzy(Action<SuggestFuzzinessDescriptor> co
274290 return Self ;
275291 }
276292
277- public CompletionSuggesterDescriptor Prefix ( string ? prefix )
293+ public CompletionSuggesterDescriptor Regex ( Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? regex )
278294 {
279- PrefixValue = prefix ;
295+ RegexDescriptor = null ;
296+ RegexDescriptorAction = null ;
297+ RegexValue = regex ;
280298 return Self ;
281299 }
282300
283- public CompletionSuggesterDescriptor Regex ( string ? regex )
301+ public CompletionSuggesterDescriptor Regex ( RegexOptionsDescriptor descriptor )
284302 {
285- RegexValue = regex ;
303+ RegexValue = null ;
304+ RegexDescriptorAction = null ;
305+ RegexDescriptor = descriptor ;
306+ return Self ;
307+ }
308+
309+ public CompletionSuggesterDescriptor Regex ( Action < RegexOptionsDescriptor > configure )
310+ {
311+ RegexValue = null ;
312+ RegexDescriptor = null ;
313+ RegexDescriptorAction = configure ;
286314 return Self ;
287315 }
288316
@@ -331,16 +359,20 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
331359 JsonSerializer . Serialize ( writer , FuzzyValue , options ) ;
332360 }
333361
334- if ( ! string . IsNullOrEmpty ( PrefixValue ) )
362+ if ( RegexDescriptor is not null )
335363 {
336- writer . WritePropertyName ( "prefix " ) ;
337- writer . WriteStringValue ( PrefixValue ) ;
364+ writer . WritePropertyName ( "regex " ) ;
365+ JsonSerializer . Serialize ( writer , RegexDescriptor , options ) ;
338366 }
339-
340- if ( ! string . IsNullOrEmpty ( RegexValue ) )
367+ else if ( RegexDescriptorAction is not null )
368+ {
369+ writer . WritePropertyName ( "regex" ) ;
370+ JsonSerializer . Serialize ( writer , new RegexOptionsDescriptor ( RegexDescriptorAction ) , options ) ;
371+ }
372+ else if ( RegexValue is not null )
341373 {
342374 writer . WritePropertyName ( "regex" ) ;
343- writer . WriteStringValue ( RegexValue ) ;
375+ JsonSerializer . Serialize ( writer , RegexValue , options ) ;
344376 }
345377
346378 if ( SizeValue . HasValue )
0 commit comments