Skip to content

Commit e260746

Browse files
Add missing Field property to IntervalsQuery (#8229) (#8230)
Co-authored-by: Florian Bernd <[email protected]>
1 parent 129fb13 commit e260746

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed

src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsQuery.g.cs

+62
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ internal IntervalsQuery(string variantName, object variant)
5858
/// </summary>
5959
[JsonInclude, JsonPropertyName("boost")]
6060
public float? Boost { get; set; }
61+
[JsonInclude, JsonPropertyName("field")]
62+
public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; }
6163
[JsonInclude, JsonPropertyName("_name")]
6264
public string? QueryName { get; set; }
6365

@@ -83,6 +85,9 @@ public override IntervalsQuery Read(ref Utf8JsonReader reader, Type typeToConver
8385
throw new JsonException("Expected start token.");
8486
}
8587

88+
reader.Read();
89+
var fieldName = reader.GetString();
90+
reader.Read();
8691
object? variantValue = default;
8792
string? variantNameValue = default;
8893
float? boostValue = default;
@@ -158,14 +163,22 @@ public override IntervalsQuery Read(ref Utf8JsonReader reader, Type typeToConver
158163
throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IntervalsQuery' from the response.");
159164
}
160165

166+
reader.Read();
161167
var result = new IntervalsQuery(variantNameValue, variantValue);
162168
result.Boost = boostValue;
169+
result.Field = fieldName;
163170
result.QueryName = queryNameValue;
164171
return result;
165172
}
166173

167174
public override void Write(Utf8JsonWriter writer, IntervalsQuery value, JsonSerializerOptions options)
168175
{
176+
if (value.Field is null)
177+
throw new JsonException("Unable to serialize IntervalsQuery because the `Field` property is not set. Field name queries must include a valid field name.");
178+
if (!options.TryGetClientSettings(out var settings))
179+
throw new JsonException("Unable to retrieve client settings required to infer field.");
180+
writer.WriteStartObject();
181+
writer.WritePropertyName(settings.Inferrer.Field(value.Field));
169182
writer.WriteStartObject();
170183
if (value.Boost.HasValue)
171184
{
@@ -206,6 +219,7 @@ public override void Write(Utf8JsonWriter writer, IntervalsQuery value, JsonSeri
206219
}
207220

208221
writer.WriteEndObject();
222+
writer.WriteEndObject();
209223
}
210224
}
211225

@@ -241,6 +255,7 @@ private IntervalsQueryDescriptor<TDocument> Set(object variant, string variantNa
241255
}
242256

243257
private float? BoostValue { get; set; }
258+
private Elastic.Clients.Elasticsearch.Serverless.Field FieldValue { get; set; }
244259
private string? QueryNameValue { get; set; }
245260

246261
/// <summary>
@@ -252,6 +267,24 @@ public IntervalsQueryDescriptor<TDocument> Boost(float? boost)
252267
return Self;
253268
}
254269

270+
public IntervalsQueryDescriptor<TDocument> Field(Elastic.Clients.Elasticsearch.Serverless.Field field)
271+
{
272+
FieldValue = field;
273+
return Self;
274+
}
275+
276+
public IntervalsQueryDescriptor<TDocument> Field<TValue>(Expression<Func<TDocument, TValue>> field)
277+
{
278+
FieldValue = field;
279+
return Self;
280+
}
281+
282+
public IntervalsQueryDescriptor<TDocument> Field(Expression<Func<TDocument, object>> field)
283+
{
284+
FieldValue = field;
285+
return Self;
286+
}
287+
255288
public IntervalsQueryDescriptor<TDocument> QueryName(string? queryName)
256289
{
257290
QueryNameValue = queryName;
@@ -273,6 +306,10 @@ public IntervalsQueryDescriptor<TDocument> QueryName(string? queryName)
273306

274307
protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
275308
{
309+
if (FieldValue is null)
310+
throw new JsonException("Unable to serialize field name query descriptor with a null field. Ensure you use a suitable descriptor constructor or call the Field method, passing a non-null value for the field argument.");
311+
writer.WriteStartObject();
312+
writer.WritePropertyName(settings.Inferrer.Field(FieldValue));
276313
writer.WriteStartObject();
277314
if (BoostValue.HasValue)
278315
{
@@ -300,6 +337,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
300337
}
301338

302339
writer.WriteEndObject();
340+
writer.WriteEndObject();
303341
}
304342
}
305343

@@ -335,6 +373,7 @@ private IntervalsQueryDescriptor Set(object variant, string variantName)
335373
}
336374

337375
private float? BoostValue { get; set; }
376+
private Elastic.Clients.Elasticsearch.Serverless.Field FieldValue { get; set; }
338377
private string? QueryNameValue { get; set; }
339378

340379
/// <summary>
@@ -346,6 +385,24 @@ public IntervalsQueryDescriptor Boost(float? boost)
346385
return Self;
347386
}
348387

388+
public IntervalsQueryDescriptor Field(Elastic.Clients.Elasticsearch.Serverless.Field field)
389+
{
390+
FieldValue = field;
391+
return Self;
392+
}
393+
394+
public IntervalsQueryDescriptor Field<TDocument, TValue>(Expression<Func<TDocument, TValue>> field)
395+
{
396+
FieldValue = field;
397+
return Self;
398+
}
399+
400+
public IntervalsQueryDescriptor Field<TDocument>(Expression<Func<TDocument, object>> field)
401+
{
402+
FieldValue = field;
403+
return Self;
404+
}
405+
349406
public IntervalsQueryDescriptor QueryName(string? queryName)
350407
{
351408
QueryNameValue = queryName;
@@ -367,6 +424,10 @@ public IntervalsQueryDescriptor QueryName(string? queryName)
367424

368425
protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
369426
{
427+
if (FieldValue is null)
428+
throw new JsonException("Unable to serialize field name query descriptor with a null field. Ensure you use a suitable descriptor constructor or call the Field method, passing a non-null value for the field argument.");
429+
writer.WriteStartObject();
430+
writer.WritePropertyName(settings.Inferrer.Field(FieldValue));
370431
writer.WriteStartObject();
371432
if (BoostValue.HasValue)
372433
{
@@ -394,5 +455,6 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
394455
}
395456

396457
writer.WriteEndObject();
458+
writer.WriteEndObject();
397459
}
398460
}

src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs

+62
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ internal IntervalsQuery(string variantName, object variant)
5858
/// </summary>
5959
[JsonInclude, JsonPropertyName("boost")]
6060
public float? Boost { get; set; }
61+
[JsonInclude, JsonPropertyName("field")]
62+
public Elastic.Clients.Elasticsearch.Field Field { get; set; }
6163
[JsonInclude, JsonPropertyName("_name")]
6264
public string? QueryName { get; set; }
6365

@@ -83,6 +85,9 @@ public override IntervalsQuery Read(ref Utf8JsonReader reader, Type typeToConver
8385
throw new JsonException("Expected start token.");
8486
}
8587

88+
reader.Read();
89+
var fieldName = reader.GetString();
90+
reader.Read();
8691
object? variantValue = default;
8792
string? variantNameValue = default;
8893
float? boostValue = default;
@@ -158,14 +163,22 @@ public override IntervalsQuery Read(ref Utf8JsonReader reader, Type typeToConver
158163
throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IntervalsQuery' from the response.");
159164
}
160165

166+
reader.Read();
161167
var result = new IntervalsQuery(variantNameValue, variantValue);
162168
result.Boost = boostValue;
169+
result.Field = fieldName;
163170
result.QueryName = queryNameValue;
164171
return result;
165172
}
166173

167174
public override void Write(Utf8JsonWriter writer, IntervalsQuery value, JsonSerializerOptions options)
168175
{
176+
if (value.Field is null)
177+
throw new JsonException("Unable to serialize IntervalsQuery because the `Field` property is not set. Field name queries must include a valid field name.");
178+
if (!options.TryGetClientSettings(out var settings))
179+
throw new JsonException("Unable to retrieve client settings required to infer field.");
180+
writer.WriteStartObject();
181+
writer.WritePropertyName(settings.Inferrer.Field(value.Field));
169182
writer.WriteStartObject();
170183
if (value.Boost.HasValue)
171184
{
@@ -206,6 +219,7 @@ public override void Write(Utf8JsonWriter writer, IntervalsQuery value, JsonSeri
206219
}
207220

208221
writer.WriteEndObject();
222+
writer.WriteEndObject();
209223
}
210224
}
211225

@@ -241,6 +255,7 @@ private IntervalsQueryDescriptor<TDocument> Set(object variant, string variantNa
241255
}
242256

243257
private float? BoostValue { get; set; }
258+
private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }
244259
private string? QueryNameValue { get; set; }
245260

246261
/// <summary>
@@ -252,6 +267,24 @@ public IntervalsQueryDescriptor<TDocument> Boost(float? boost)
252267
return Self;
253268
}
254269

270+
public IntervalsQueryDescriptor<TDocument> Field(Elastic.Clients.Elasticsearch.Field field)
271+
{
272+
FieldValue = field;
273+
return Self;
274+
}
275+
276+
public IntervalsQueryDescriptor<TDocument> Field<TValue>(Expression<Func<TDocument, TValue>> field)
277+
{
278+
FieldValue = field;
279+
return Self;
280+
}
281+
282+
public IntervalsQueryDescriptor<TDocument> Field(Expression<Func<TDocument, object>> field)
283+
{
284+
FieldValue = field;
285+
return Self;
286+
}
287+
255288
public IntervalsQueryDescriptor<TDocument> QueryName(string? queryName)
256289
{
257290
QueryNameValue = queryName;
@@ -273,6 +306,10 @@ public IntervalsQueryDescriptor<TDocument> QueryName(string? queryName)
273306

274307
protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
275308
{
309+
if (FieldValue is null)
310+
throw new JsonException("Unable to serialize field name query descriptor with a null field. Ensure you use a suitable descriptor constructor or call the Field method, passing a non-null value for the field argument.");
311+
writer.WriteStartObject();
312+
writer.WritePropertyName(settings.Inferrer.Field(FieldValue));
276313
writer.WriteStartObject();
277314
if (BoostValue.HasValue)
278315
{
@@ -300,6 +337,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
300337
}
301338

302339
writer.WriteEndObject();
340+
writer.WriteEndObject();
303341
}
304342
}
305343

@@ -335,6 +373,7 @@ private IntervalsQueryDescriptor Set(object variant, string variantName)
335373
}
336374

337375
private float? BoostValue { get; set; }
376+
private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }
338377
private string? QueryNameValue { get; set; }
339378

340379
/// <summary>
@@ -346,6 +385,24 @@ public IntervalsQueryDescriptor Boost(float? boost)
346385
return Self;
347386
}
348387

388+
public IntervalsQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field)
389+
{
390+
FieldValue = field;
391+
return Self;
392+
}
393+
394+
public IntervalsQueryDescriptor Field<TDocument, TValue>(Expression<Func<TDocument, TValue>> field)
395+
{
396+
FieldValue = field;
397+
return Self;
398+
}
399+
400+
public IntervalsQueryDescriptor Field<TDocument>(Expression<Func<TDocument, object>> field)
401+
{
402+
FieldValue = field;
403+
return Self;
404+
}
405+
349406
public IntervalsQueryDescriptor QueryName(string? queryName)
350407
{
351408
QueryNameValue = queryName;
@@ -367,6 +424,10 @@ public IntervalsQueryDescriptor QueryName(string? queryName)
367424

368425
protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
369426
{
427+
if (FieldValue is null)
428+
throw new JsonException("Unable to serialize field name query descriptor with a null field. Ensure you use a suitable descriptor constructor or call the Field method, passing a non-null value for the field argument.");
429+
writer.WriteStartObject();
430+
writer.WritePropertyName(settings.Inferrer.Field(FieldValue));
370431
writer.WriteStartObject();
371432
if (BoostValue.HasValue)
372433
{
@@ -394,5 +455,6 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
394455
}
395456

396457
writer.WriteEndObject();
458+
writer.WriteEndObject();
397459
}
398460
}

0 commit comments

Comments
 (0)