@@ -37,10 +37,8 @@ public sealed partial class CompletionSuggester
37
37
public Elastic . Clients . Elasticsearch . Field Field { get ; set ; }
38
38
[ JsonInclude , JsonPropertyName ( "fuzzy" ) ]
39
39
public Elastic . Clients . Elasticsearch . Core . Search . SuggestFuzziness ? Fuzzy { get ; set ; }
40
- [ JsonInclude , JsonPropertyName ( "prefix" ) ]
41
- public string ? Prefix { get ; set ; }
42
40
[ JsonInclude , JsonPropertyName ( "regex" ) ]
43
- public string ? Regex { get ; set ; }
41
+ public Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? Regex { get ; set ; }
44
42
[ JsonInclude , JsonPropertyName ( "size" ) ]
45
43
public int ? Size { get ; set ; }
46
44
[ JsonInclude , JsonPropertyName ( "skip_duplicates" ) ]
@@ -63,8 +61,9 @@ public CompletionSuggesterDescriptor() : base()
63
61
private Elastic . Clients . Elasticsearch . Core . Search . SuggestFuzziness ? FuzzyValue { get ; set ; }
64
62
private SuggestFuzzinessDescriptor FuzzyDescriptor { get ; set ; }
65
63
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 ; }
68
67
private int ? SizeValue { get ; set ; }
69
68
private bool ? SkipDuplicatesValue { get ; set ; }
70
69
@@ -116,15 +115,27 @@ public CompletionSuggesterDescriptor<TDocument> Fuzzy(Action<SuggestFuzzinessDes
116
115
return Self ;
117
116
}
118
117
119
- public CompletionSuggesterDescriptor < TDocument > Prefix ( string ? prefix )
118
+ public CompletionSuggesterDescriptor < TDocument > Regex ( Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? regex )
120
119
{
121
- PrefixValue = prefix ;
120
+ RegexDescriptor = null ;
121
+ RegexDescriptorAction = null ;
122
+ RegexValue = regex ;
122
123
return Self ;
123
124
}
124
125
125
- public CompletionSuggesterDescriptor < TDocument > Regex ( string ? regex )
126
+ public CompletionSuggesterDescriptor < TDocument > Regex ( RegexOptionsDescriptor descriptor )
126
127
{
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 ;
128
139
return Self ;
129
140
}
130
141
@@ -173,16 +184,20 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
173
184
JsonSerializer . Serialize ( writer , FuzzyValue , options ) ;
174
185
}
175
186
176
- if ( ! string . IsNullOrEmpty ( PrefixValue ) )
187
+ if ( RegexDescriptor is not null )
177
188
{
178
- writer . WritePropertyName ( "prefix " ) ;
179
- writer . WriteStringValue ( PrefixValue ) ;
189
+ writer . WritePropertyName ( "regex " ) ;
190
+ JsonSerializer . Serialize ( writer , RegexDescriptor , options ) ;
180
191
}
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 )
183
198
{
184
199
writer . WritePropertyName ( "regex" ) ;
185
- writer . WriteStringValue ( RegexValue ) ;
200
+ JsonSerializer . Serialize ( writer , RegexValue , options ) ;
186
201
}
187
202
188
203
if ( SizeValue . HasValue )
@@ -215,8 +230,9 @@ public CompletionSuggesterDescriptor() : base()
215
230
private Elastic . Clients . Elasticsearch . Core . Search . SuggestFuzziness ? FuzzyValue { get ; set ; }
216
231
private SuggestFuzzinessDescriptor FuzzyDescriptor { get ; set ; }
217
232
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 ; }
220
236
private int ? SizeValue { get ; set ; }
221
237
private bool ? SkipDuplicatesValue { get ; set ; }
222
238
@@ -274,15 +290,27 @@ public CompletionSuggesterDescriptor Fuzzy(Action<SuggestFuzzinessDescriptor> co
274
290
return Self ;
275
291
}
276
292
277
- public CompletionSuggesterDescriptor Prefix ( string ? prefix )
293
+ public CompletionSuggesterDescriptor Regex ( Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? regex )
278
294
{
279
- PrefixValue = prefix ;
295
+ RegexDescriptor = null ;
296
+ RegexDescriptorAction = null ;
297
+ RegexValue = regex ;
280
298
return Self ;
281
299
}
282
300
283
- public CompletionSuggesterDescriptor Regex ( string ? regex )
301
+ public CompletionSuggesterDescriptor Regex ( RegexOptionsDescriptor descriptor )
284
302
{
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 ;
286
314
return Self ;
287
315
}
288
316
@@ -331,16 +359,20 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
331
359
JsonSerializer . Serialize ( writer , FuzzyValue , options ) ;
332
360
}
333
361
334
- if ( ! string . IsNullOrEmpty ( PrefixValue ) )
362
+ if ( RegexDescriptor is not null )
335
363
{
336
- writer . WritePropertyName ( "prefix " ) ;
337
- writer . WriteStringValue ( PrefixValue ) ;
364
+ writer . WritePropertyName ( "regex " ) ;
365
+ JsonSerializer . Serialize ( writer , RegexDescriptor , options ) ;
338
366
}
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 )
341
373
{
342
374
writer . WritePropertyName ( "regex" ) ;
343
- writer . WriteStringValue ( RegexValue ) ;
375
+ JsonSerializer . Serialize ( writer , RegexValue , options ) ;
344
376
}
345
377
346
378
if ( SizeValue . HasValue )
0 commit comments