From 45148ae9cfda11ef674fff225676400993c1b6a1 Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Tue, 11 Jun 2024 15:32:27 +0200 Subject: [PATCH] Add missing `Field` property to `IntervalsQuery` (#8229) --- .../Types/QueryDsl/IntervalsQuery.g.cs | 62 +++++++++++++++++++ .../Types/QueryDsl/IntervalsQuery.g.cs | 62 +++++++++++++++++++ 2 files changed, 124 insertions(+) diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsQuery.g.cs index 50905180755..ba8e920fc2b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsQuery.g.cs @@ -58,6 +58,8 @@ internal IntervalsQuery(string variantName, object variant) /// [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } + [JsonInclude, JsonPropertyName("field")] + public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; } [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } @@ -83,6 +85,9 @@ public override IntervalsQuery Read(ref Utf8JsonReader reader, Type typeToConver throw new JsonException("Expected start token."); } + reader.Read(); + var fieldName = reader.GetString(); + reader.Read(); object? variantValue = default; string? variantNameValue = default; float? boostValue = default; @@ -158,14 +163,22 @@ public override IntervalsQuery Read(ref Utf8JsonReader reader, Type typeToConver throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IntervalsQuery' from the response."); } + reader.Read(); var result = new IntervalsQuery(variantNameValue, variantValue); result.Boost = boostValue; + result.Field = fieldName; result.QueryName = queryNameValue; return result; } public override void Write(Utf8JsonWriter writer, IntervalsQuery value, JsonSerializerOptions options) { + if (value.Field is null) + throw new JsonException("Unable to serialize IntervalsQuery because the `Field` property is not set. Field name queries must include a valid field name."); + if (!options.TryGetClientSettings(out var settings)) + throw new JsonException("Unable to retrieve client settings required to infer field."); + writer.WriteStartObject(); + writer.WritePropertyName(settings.Inferrer.Field(value.Field)); writer.WriteStartObject(); if (value.Boost.HasValue) { @@ -206,6 +219,7 @@ public override void Write(Utf8JsonWriter writer, IntervalsQuery value, JsonSeri } writer.WriteEndObject(); + writer.WriteEndObject(); } } @@ -241,6 +255,7 @@ private IntervalsQueryDescriptor Set(object variant, string variantNa } private float? BoostValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Field FieldValue { get; set; } private string? QueryNameValue { get; set; } /// @@ -252,6 +267,24 @@ public IntervalsQueryDescriptor Boost(float? boost) return Self; } + public IntervalsQueryDescriptor Field(Elastic.Clients.Elasticsearch.Serverless.Field field) + { + FieldValue = field; + return Self; + } + + public IntervalsQueryDescriptor Field(Expression> field) + { + FieldValue = field; + return Self; + } + + public IntervalsQueryDescriptor Field(Expression> field) + { + FieldValue = field; + return Self; + } + public IntervalsQueryDescriptor QueryName(string? queryName) { QueryNameValue = queryName; @@ -273,6 +306,10 @@ public IntervalsQueryDescriptor QueryName(string? queryName) protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { + if (FieldValue is null) + 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."); + writer.WriteStartObject(); + writer.WritePropertyName(settings.Inferrer.Field(FieldValue)); writer.WriteStartObject(); if (BoostValue.HasValue) { @@ -300,6 +337,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o } writer.WriteEndObject(); + writer.WriteEndObject(); } } @@ -335,6 +373,7 @@ private IntervalsQueryDescriptor Set(object variant, string variantName) } private float? BoostValue { get; set; } + private Elastic.Clients.Elasticsearch.Serverless.Field FieldValue { get; set; } private string? QueryNameValue { get; set; } /// @@ -346,6 +385,24 @@ public IntervalsQueryDescriptor Boost(float? boost) return Self; } + public IntervalsQueryDescriptor Field(Elastic.Clients.Elasticsearch.Serverless.Field field) + { + FieldValue = field; + return Self; + } + + public IntervalsQueryDescriptor Field(Expression> field) + { + FieldValue = field; + return Self; + } + + public IntervalsQueryDescriptor Field(Expression> field) + { + FieldValue = field; + return Self; + } + public IntervalsQueryDescriptor QueryName(string? queryName) { QueryNameValue = queryName; @@ -367,6 +424,10 @@ public IntervalsQueryDescriptor QueryName(string? queryName) protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { + if (FieldValue is null) + 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."); + writer.WriteStartObject(); + writer.WritePropertyName(settings.Inferrer.Field(FieldValue)); writer.WriteStartObject(); if (BoostValue.HasValue) { @@ -394,5 +455,6 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o } writer.WriteEndObject(); + writer.WriteEndObject(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs index d7aa70b0fc5..55627c70adc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs @@ -58,6 +58,8 @@ internal IntervalsQuery(string variantName, object variant) /// [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } + [JsonInclude, JsonPropertyName("field")] + public Elastic.Clients.Elasticsearch.Field Field { get; set; } [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } @@ -83,6 +85,9 @@ public override IntervalsQuery Read(ref Utf8JsonReader reader, Type typeToConver throw new JsonException("Expected start token."); } + reader.Read(); + var fieldName = reader.GetString(); + reader.Read(); object? variantValue = default; string? variantNameValue = default; float? boostValue = default; @@ -158,14 +163,22 @@ public override IntervalsQuery Read(ref Utf8JsonReader reader, Type typeToConver throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IntervalsQuery' from the response."); } + reader.Read(); var result = new IntervalsQuery(variantNameValue, variantValue); result.Boost = boostValue; + result.Field = fieldName; result.QueryName = queryNameValue; return result; } public override void Write(Utf8JsonWriter writer, IntervalsQuery value, JsonSerializerOptions options) { + if (value.Field is null) + throw new JsonException("Unable to serialize IntervalsQuery because the `Field` property is not set. Field name queries must include a valid field name."); + if (!options.TryGetClientSettings(out var settings)) + throw new JsonException("Unable to retrieve client settings required to infer field."); + writer.WriteStartObject(); + writer.WritePropertyName(settings.Inferrer.Field(value.Field)); writer.WriteStartObject(); if (value.Boost.HasValue) { @@ -206,6 +219,7 @@ public override void Write(Utf8JsonWriter writer, IntervalsQuery value, JsonSeri } writer.WriteEndObject(); + writer.WriteEndObject(); } } @@ -241,6 +255,7 @@ private IntervalsQueryDescriptor Set(object variant, string variantNa } private float? BoostValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string? QueryNameValue { get; set; } /// @@ -252,6 +267,24 @@ public IntervalsQueryDescriptor Boost(float? boost) return Self; } + public IntervalsQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) + { + FieldValue = field; + return Self; + } + + public IntervalsQueryDescriptor Field(Expression> field) + { + FieldValue = field; + return Self; + } + + public IntervalsQueryDescriptor Field(Expression> field) + { + FieldValue = field; + return Self; + } + public IntervalsQueryDescriptor QueryName(string? queryName) { QueryNameValue = queryName; @@ -273,6 +306,10 @@ public IntervalsQueryDescriptor QueryName(string? queryName) protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { + if (FieldValue is null) + 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."); + writer.WriteStartObject(); + writer.WritePropertyName(settings.Inferrer.Field(FieldValue)); writer.WriteStartObject(); if (BoostValue.HasValue) { @@ -300,6 +337,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o } writer.WriteEndObject(); + writer.WriteEndObject(); } } @@ -335,6 +373,7 @@ private IntervalsQueryDescriptor Set(object variant, string variantName) } private float? BoostValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string? QueryNameValue { get; set; } /// @@ -346,6 +385,24 @@ public IntervalsQueryDescriptor Boost(float? boost) return Self; } + public IntervalsQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) + { + FieldValue = field; + return Self; + } + + public IntervalsQueryDescriptor Field(Expression> field) + { + FieldValue = field; + return Self; + } + + public IntervalsQueryDescriptor Field(Expression> field) + { + FieldValue = field; + return Self; + } + public IntervalsQueryDescriptor QueryName(string? queryName) { QueryNameValue = queryName; @@ -367,6 +424,10 @@ public IntervalsQueryDescriptor QueryName(string? queryName) protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { + if (FieldValue is null) + 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."); + writer.WriteStartObject(); + writer.WritePropertyName(settings.Inferrer.Field(FieldValue)); writer.WriteStartObject(); if (BoostValue.HasValue) { @@ -394,5 +455,6 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o } writer.WriteEndObject(); + writer.WriteEndObject(); } } \ No newline at end of file