@@ -38,13 +38,8 @@ public sealed partial class CompletionSuggester
38
38
39
39
[ JsonInclude , JsonPropertyName ( "fuzzy" ) ]
40
40
public Elastic . Clients . Elasticsearch . Core . Search . SuggestFuzziness ? Fuzzy { get ; set ; }
41
-
42
- [ JsonInclude , JsonPropertyName ( "prefix" ) ]
43
- public string ? Prefix { get ; set ; }
44
-
45
41
[ JsonInclude , JsonPropertyName ( "regex" ) ]
46
- public string ? Regex { get ; set ; }
47
-
42
+ public Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? Regex { get ; set ; }
48
43
[ JsonInclude , JsonPropertyName ( "size" ) ]
49
44
public int ? Size { get ; set ; }
50
45
@@ -72,11 +67,9 @@ public CompletionSuggesterDescriptor() : base()
72
67
private SuggestFuzzinessDescriptor FuzzyDescriptor { get ; set ; }
73
68
74
69
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 ; }
80
73
private int ? SizeValue { get ; set ; }
81
74
82
75
private bool ? SkipDuplicatesValue { get ; set ; }
@@ -129,15 +122,27 @@ public CompletionSuggesterDescriptor<TDocument> Fuzzy(Action<SuggestFuzzinessDes
129
122
return Self ;
130
123
}
131
124
132
- public CompletionSuggesterDescriptor < TDocument > Prefix ( string ? prefix )
125
+ public CompletionSuggesterDescriptor < TDocument > Regex ( Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? regex )
133
126
{
134
- PrefixValue = prefix ;
127
+ RegexDescriptor = null ;
128
+ RegexDescriptorAction = null ;
129
+ RegexValue = regex ;
135
130
return Self ;
136
131
}
137
132
138
- public CompletionSuggesterDescriptor < TDocument > Regex ( string ? regex )
133
+ public CompletionSuggesterDescriptor < TDocument > Regex ( RegexOptionsDescriptor descriptor )
139
134
{
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 ;
141
146
return Self ;
142
147
}
143
148
@@ -186,16 +191,20 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
186
191
JsonSerializer . Serialize ( writer , FuzzyValue , options ) ;
187
192
}
188
193
189
- if ( ! string . IsNullOrEmpty ( PrefixValue ) )
194
+ if ( RegexDescriptor is not null )
190
195
{
191
- writer . WritePropertyName ( "prefix " ) ;
192
- writer . WriteStringValue ( PrefixValue ) ;
196
+ writer . WritePropertyName ( "regex " ) ;
197
+ JsonSerializer . Serialize ( writer , RegexDescriptor , options ) ;
193
198
}
194
-
195
- if ( ! string . IsNullOrEmpty ( RegexValue ) )
199
+ else if ( RegexDescriptorAction is not null )
196
200
{
197
201
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 ) ;
199
208
}
200
209
201
210
if ( SizeValue . HasValue )
@@ -232,11 +241,9 @@ public CompletionSuggesterDescriptor() : base()
232
241
private SuggestFuzzinessDescriptor FuzzyDescriptor { get ; set ; }
233
242
234
243
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 ; }
240
247
private int ? SizeValue { get ; set ; }
241
248
242
249
private bool ? SkipDuplicatesValue { get ; set ; }
@@ -295,15 +302,27 @@ public CompletionSuggesterDescriptor Fuzzy(Action<SuggestFuzzinessDescriptor> co
295
302
return Self ;
296
303
}
297
304
298
- public CompletionSuggesterDescriptor Prefix ( string ? prefix )
305
+ public CompletionSuggesterDescriptor Regex ( Elastic . Clients . Elasticsearch . Core . Search . RegexOptions ? regex )
299
306
{
300
- PrefixValue = prefix ;
307
+ RegexDescriptor = null ;
308
+ RegexDescriptorAction = null ;
309
+ RegexValue = regex ;
301
310
return Self ;
302
311
}
303
312
304
- public CompletionSuggesterDescriptor Regex ( string ? regex )
313
+ public CompletionSuggesterDescriptor Regex ( RegexOptionsDescriptor descriptor )
305
314
{
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 ;
307
326
return Self ;
308
327
}
309
328
@@ -352,16 +371,20 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
352
371
JsonSerializer . Serialize ( writer , FuzzyValue , options ) ;
353
372
}
354
373
355
- if ( ! string . IsNullOrEmpty ( PrefixValue ) )
374
+ if ( RegexDescriptor is not null )
356
375
{
357
- writer . WritePropertyName ( "prefix " ) ;
358
- writer . WriteStringValue ( PrefixValue ) ;
376
+ writer . WritePropertyName ( "regex " ) ;
377
+ JsonSerializer . Serialize ( writer , RegexDescriptor , options ) ;
359
378
}
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 )
362
385
{
363
386
writer . WritePropertyName ( "regex" ) ;
364
- writer . WriteStringValue ( RegexValue ) ;
387
+ JsonSerializer . Serialize ( writer , RegexValue , options ) ;
365
388
}
366
389
367
390
if ( SizeValue . HasValue )
0 commit comments