diff --git a/.ci/DockerFile b/.ci/DockerFile index c0cfaa2750c..07b2af1d461 100644 --- a/.ci/DockerFile +++ b/.ci/DockerFile @@ -1,4 +1,4 @@ -ARG DOTNET_VERSION=6.0.401 +ARG DOTNET_VERSION=6.0.403 FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS elasticsearch-net-build ARG USER_ID diff --git a/.ci/make.sh b/.ci/make.sh index 9172cf329a1..52c488d4805 100755 --- a/.ci/make.sh +++ b/.ci/make.sh @@ -42,7 +42,7 @@ OUTPUT_DIR="$repo/${output_folder}" REPO_BINDING="${OUTPUT_DIR}:/sln/${output_folder}" mkdir -p "$OUTPUT_DIR" -DOTNET_VERSION=${DOTNET_VERSION-6.0.401} +DOTNET_VERSION=${DOTNET_VERSION-6.0.403} echo -e "\033[34;1mINFO:\033[0m PRODUCT ${product}\033[0m" echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m" diff --git a/.ci/readme.md b/.ci/readme.md index 8c6c78c6ca6..82766281271 100644 --- a/.ci/readme.md +++ b/.ci/readme.md @@ -30,7 +30,7 @@ $ STACK_VERSION=8.0.0-SNAPSHOT ./.ci/run-tests |-------------------------|-------------|-------------| | `STACK_VERSION` | `N/A` | The elasticsearch version to target | `TEST_SUITE` | `basic` | `free` or `platinum` sets which test suite to run and which container to run against. | -| `DOTNET_VERSION` | `6.0.401` | The .NET sdk version used to grab the proper container | +| `DOTNET_VERSION` | `6.0.403` | The .NET sdk version used to grab the proper container | If you want to manually spin up elasticsearch for these tests and call the runner afterwards you can use diff --git a/.ci/run-repository.ps1 b/.ci/run-repository.ps1 index 3d762cad534..3c462f187d0 100644 --- a/.ci/run-repository.ps1 +++ b/.ci/run-repository.ps1 @@ -14,7 +14,7 @@ param( $NODE_NAME, [string] - $DOTNET_VERSION = "6.0.401" + $DOTNET_VERSION = "6.0.403" ) $ESC = [char]27 diff --git a/.ci/run-repository.sh b/.ci/run-repository.sh index bb2e51afd85..576832ba7bd 100755 --- a/.ci/run-repository.sh +++ b/.ci/run-repository.sh @@ -9,7 +9,7 @@ script_path=$(dirname $(realpath -s $0)) source $script_path/functions/imports.sh set -euo pipefail -DOTNET_VERSION=${DOTNET_VERSION-6.0.401} +DOTNET_VERSION=${DOTNET_VERSION-6.0.403} ELASTICSEARCH_URL=${ELASTICSEARCH_URL-"$elasticsearch_url"} elasticsearch_container=${elasticsearch_container-} diff --git a/.ci/run-tests.ps1 b/.ci/run-tests.ps1 index 9057f7b3b75..9eb93b6557a 100644 --- a/.ci/run-tests.ps1 +++ b/.ci/run-tests.ps1 @@ -8,7 +8,7 @@ param ( $TEST_SUITE = "free", [string] - $DOTNET_VERSION = "6.0.401" + $DOTNET_VERSION = "6.0.403" ) $ESC = [char]27 diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml index f9a850bee25..01fed677b23 100755 --- a/.ci/test-matrix.yml +++ b/.ci/test-matrix.yml @@ -8,6 +8,6 @@ TEST_SUITE: - platinum DOTNET_VERSION: - - 6.0.401 + - 6.0.403 exclude: ~ diff --git a/.github/workflows/integration-jobs.yml b/.github/workflows/integration-jobs.yml index 80848d2287c..4cee0e22f11 100644 --- a/.github/workflows/integration-jobs.yml +++ b/.github/workflows/integration-jobs.yml @@ -36,7 +36,7 @@ jobs: uses: actions/checkout@v2 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.401' + dotnet-version: '6.0.403' - uses: actions/cache@v2 with: path: ~/.nuget/packages diff --git a/.github/workflows/make-bump.yml b/.github/workflows/make-bump.yml index 7d02b394441..65cad2039be 100644 --- a/.github/workflows/make-bump.yml +++ b/.github/workflows/make-bump.yml @@ -35,7 +35,7 @@ jobs: # Add version and backport labels automatically - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.401' + dotnet-version: '6.0.403' - name: Install dotnet-script run: dotnet tool install release-notes --tool-path dotnet-tool diff --git a/.github/workflows/make-release-notes.yml b/.github/workflows/make-release-notes.yml index fd2acd38a8a..361842cb899 100644 --- a/.github/workflows/make-release-notes.yml +++ b/.github/workflows/make-release-notes.yml @@ -51,7 +51,7 @@ jobs: - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.401' + dotnet-version: '6.0.403' - name: Install dotnet-script run: dotnet tool install release-notes --tool-path dotnet-tool diff --git a/.github/workflows/stale-jobs.yml b/.github/workflows/stale-jobs.yml index b504f4f923b..4a7bb6cae94 100644 --- a/.github/workflows/stale-jobs.yml +++ b/.github/workflows/stale-jobs.yml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@v2 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.401' + dotnet-version: '6.0.403' - uses: actions/cache@v2 with: path: ~/.nuget/packages diff --git a/.github/workflows/test-jobs.yml b/.github/workflows/test-jobs.yml index 8c5ba564574..c083492013b 100644 --- a/.github/workflows/test-jobs.yml +++ b/.github/workflows/test-jobs.yml @@ -23,7 +23,7 @@ jobs: uses: actions/checkout@v2 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.401' + dotnet-version: '6.0.403' - uses: actions/cache@v2 with: path: ~/.nuget/packages @@ -53,7 +53,7 @@ jobs: uses: actions/checkout@v2 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.401' + dotnet-version: '6.0.403' - uses: actions/cache@v2 with: path: ~/.nuget/packages diff --git a/.github/workflows/unified-release.yml b/.github/workflows/unified-release.yml index 54f6a2f57d6..ae49a51cc1f 100644 --- a/.github/workflows/unified-release.yml +++ b/.github/workflows/unified-release.yml @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@v2 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.401' + dotnet-version: '6.0.403' - run: "./.ci/make.sh assemble ${{ matrix.stack_version }}" name: Assemble ${{ matrix.stack_version }} \ No newline at end of file diff --git a/global.json b/global.json index 9e1c9458415..1ecc7cf4d03 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.401", + "version": "6.0.403", "rollForward": "minor", "allowPrerelease": false }, diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs index c99a25ec40e..884750812a6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs @@ -451,62 +451,6 @@ public override void Write(Utf8JsonWriter writer, FieldSortNumericType value, Js } } -[JsonConverter(typeof(GeoShapeRelationConverter))] -public enum GeoShapeRelation -{ - [EnumMember(Value = "within")] - Within, - [EnumMember(Value = "intersects")] - Intersects, - [EnumMember(Value = "disjoint")] - Disjoint, - [EnumMember(Value = "contains")] - Contains -} - -internal sealed class GeoShapeRelationConverter : JsonConverter -{ - public override GeoShapeRelation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var enumString = reader.GetString(); - switch (enumString) - { - case "within": - return GeoShapeRelation.Within; - case "intersects": - return GeoShapeRelation.Intersects; - case "disjoint": - return GeoShapeRelation.Disjoint; - case "contains": - return GeoShapeRelation.Contains; - } - - ThrowHelper.ThrowJsonException(); - return default; - } - - public override void Write(Utf8JsonWriter writer, GeoShapeRelation value, JsonSerializerOptions options) - { - switch (value) - { - case GeoShapeRelation.Within: - writer.WriteStringValue("within"); - return; - case GeoShapeRelation.Intersects: - writer.WriteStringValue("intersects"); - return; - case GeoShapeRelation.Disjoint: - writer.WriteStringValue("disjoint"); - return; - case GeoShapeRelation.Contains: - writer.WriteStringValue("contains"); - return; - } - - writer.WriteNullValue(); - } -} - [JsonConverter(typeof(HealthStatusConverter))] public enum HealthStatus { diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldLookup.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldLookup.g.cs deleted file mode 100644 index 2ea3c548659..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldLookup.g.cs +++ /dev/null @@ -1,195 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. -// -// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ -// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ -// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ -// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ -// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ -// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ -// ------------------------------------------------ -// -// This file is automatically generated. -// Please do not edit these files manually. -// -// ------------------------------------------------ - -using Elastic.Clients.Elasticsearch.Fluent; -using Elastic.Clients.Elasticsearch.Serialization; -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Text.Json; -using System.Text.Json.Serialization; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.QueryDsl; -public sealed partial class FieldLookup -{ - [JsonInclude] - [JsonPropertyName("id")] - public Elastic.Clients.Elasticsearch.Id Id { get; set; } - - [JsonInclude] - [JsonPropertyName("index")] - public Elastic.Clients.Elasticsearch.IndexName? Index { get; set; } - - [JsonInclude] - [JsonPropertyName("path")] - public Elastic.Clients.Elasticsearch.Field? Path { get; set; } - - [JsonInclude] - [JsonPropertyName("routing")] - public Elastic.Clients.Elasticsearch.Routing? Routing { get; set; } -} - -public sealed partial class FieldLookupDescriptor : SerializableDescriptor> -{ - internal FieldLookupDescriptor(Action> configure) => configure.Invoke(this); - public FieldLookupDescriptor() : base() - { - } - - private Elastic.Clients.Elasticsearch.Id IdValue { get; set; } - - private Elastic.Clients.Elasticsearch.IndexName? IndexValue { get; set; } - - private Elastic.Clients.Elasticsearch.Field? PathValue { get; set; } - - private Elastic.Clients.Elasticsearch.Routing? RoutingValue { get; set; } - - public FieldLookupDescriptor Id(Elastic.Clients.Elasticsearch.Id id) - { - IdValue = id; - return Self; - } - - public FieldLookupDescriptor Index(Elastic.Clients.Elasticsearch.IndexName? index) - { - IndexValue = index; - return Self; - } - - public FieldLookupDescriptor Path(Elastic.Clients.Elasticsearch.Field? path) - { - PathValue = path; - return Self; - } - - public FieldLookupDescriptor Path(Expression> path) - { - PathValue = path; - return Self; - } - - public FieldLookupDescriptor Routing(Elastic.Clients.Elasticsearch.Routing? routing) - { - RoutingValue = routing; - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - writer.WriteStartObject(); - writer.WritePropertyName("id"); - JsonSerializer.Serialize(writer, IdValue, options); - if (IndexValue is not null) - { - writer.WritePropertyName("index"); - JsonSerializer.Serialize(writer, IndexValue, options); - } - - if (PathValue is not null) - { - writer.WritePropertyName("path"); - JsonSerializer.Serialize(writer, PathValue, options); - } - - if (RoutingValue is not null) - { - writer.WritePropertyName("routing"); - JsonSerializer.Serialize(writer, RoutingValue, options); - } - - writer.WriteEndObject(); - } -} - -public sealed partial class FieldLookupDescriptor : SerializableDescriptor -{ - internal FieldLookupDescriptor(Action configure) => configure.Invoke(this); - public FieldLookupDescriptor() : base() - { - } - - private Elastic.Clients.Elasticsearch.Id IdValue { get; set; } - - private Elastic.Clients.Elasticsearch.IndexName? IndexValue { get; set; } - - private Elastic.Clients.Elasticsearch.Field? PathValue { get; set; } - - private Elastic.Clients.Elasticsearch.Routing? RoutingValue { get; set; } - - public FieldLookupDescriptor Id(Elastic.Clients.Elasticsearch.Id id) - { - IdValue = id; - return Self; - } - - public FieldLookupDescriptor Index(Elastic.Clients.Elasticsearch.IndexName? index) - { - IndexValue = index; - return Self; - } - - public FieldLookupDescriptor Path(Elastic.Clients.Elasticsearch.Field? path) - { - PathValue = path; - return Self; - } - - public FieldLookupDescriptor Path(Expression> path) - { - PathValue = path; - return Self; - } - - public FieldLookupDescriptor Path(Expression> path) - { - PathValue = path; - return Self; - } - - public FieldLookupDescriptor Routing(Elastic.Clients.Elasticsearch.Routing? routing) - { - RoutingValue = routing; - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - writer.WriteStartObject(); - writer.WritePropertyName("id"); - JsonSerializer.Serialize(writer, IdValue, options); - if (IndexValue is not null) - { - writer.WritePropertyName("index"); - JsonSerializer.Serialize(writer, IndexValue, options); - } - - if (PathValue is not null) - { - writer.WritePropertyName("path"); - JsonSerializer.Serialize(writer, PathValue, options); - } - - if (RoutingValue is not null) - { - writer.WritePropertyName("routing"); - JsonSerializer.Serialize(writer, RoutingValue, options); - } - - writer.WriteEndObject(); - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryContainer.g.cs index 920937cd22b..aaa3a7280bc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryContainer.g.cs @@ -75,7 +75,6 @@ internal QueryContainer(string variantName, object variant) public static QueryContainer Regexp(Elastic.Clients.Elasticsearch.QueryDsl.RegexpQuery regexpQuery) => new QueryContainer("regexp", regexpQuery); public static QueryContainer Script(Elastic.Clients.Elasticsearch.QueryDsl.ScriptQuery scriptQuery) => new QueryContainer("script", scriptQuery); public static QueryContainer ScriptScore(Elastic.Clients.Elasticsearch.QueryDsl.ScriptScoreQuery scriptScoreQuery) => new QueryContainer("script_score", scriptScoreQuery); - public static QueryContainer Shape(Elastic.Clients.Elasticsearch.QueryDsl.ShapeQuery shapeQuery) => new QueryContainer("shape", shapeQuery); public static QueryContainer SimpleQueryString(Elastic.Clients.Elasticsearch.QueryDsl.SimpleQueryStringQuery simpleQueryStringQuery) => new QueryContainer("simple_query_string", simpleQueryStringQuery); public static QueryContainer SpanContaining(Elastic.Clients.Elasticsearch.QueryDsl.SpanContainingQuery spanContainingQuery) => new QueryContainer("span_containing", spanContainingQuery); public static QueryContainer SpanFirst(Elastic.Clients.Elasticsearch.QueryDsl.SpanFirstQuery spanFirstQuery) => new QueryContainer("span_first", spanFirstQuery); @@ -326,13 +325,6 @@ public override QueryContainer Read(ref Utf8JsonReader reader, Type typeToConver return new QueryContainer(propertyName, variant); } - if (propertyName == "shape") - { - var variant = JsonSerializer.Deserialize(ref reader, options); - reader.Read(); - return new QueryContainer(propertyName, variant); - } - if (propertyName == "simple_query_string") { var variant = JsonSerializer.Deserialize(ref reader, options); @@ -533,9 +525,6 @@ public override void Write(Utf8JsonWriter writer, QueryContainer value, JsonSeri case "script_score": JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptScoreQuery)value.Variant, options); break; - case "shape": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ShapeQuery)value.Variant, options); - break; case "simple_query_string": JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SimpleQueryStringQuery)value.Variant, options); break; @@ -679,8 +668,6 @@ private QueryContainerDescriptor Set(object variant, string variantNa public QueryContainerDescriptor Script(Action configure) => Set(configure, "script"); public QueryContainerDescriptor ScriptScore(ScriptScoreQuery scriptScoreQuery) => Set(scriptScoreQuery, "script_score"); public QueryContainerDescriptor ScriptScore(Action> configure) => Set(configure, "script_score"); - public QueryContainerDescriptor Shape(ShapeQuery shapeQuery) => Set(shapeQuery, "shape"); - public QueryContainerDescriptor Shape(Action> configure) => Set(configure, "shape"); public QueryContainerDescriptor SimpleQueryString(SimpleQueryStringQuery simpleQueryStringQuery) => Set(simpleQueryStringQuery, "simple_query_string"); public QueryContainerDescriptor SimpleQueryString(Action> configure) => Set(configure, "simple_query_string"); public QueryContainerDescriptor SpanContaining(SpanContainingQuery spanContainingQuery) => Set(spanContainingQuery, "span_containing"); @@ -851,9 +838,6 @@ private QueryContainerDescriptor Set(object variant, string variantName) public QueryContainerDescriptor ScriptScore(ScriptScoreQuery scriptScoreQuery) => Set(scriptScoreQuery, "script_score"); public QueryContainerDescriptor ScriptScore(Action configure) => Set(configure, "script_score"); public QueryContainerDescriptor ScriptScore(Action> configure) => Set(configure, "script_score"); - public QueryContainerDescriptor Shape(ShapeQuery shapeQuery) => Set(shapeQuery, "shape"); - public QueryContainerDescriptor Shape(Action configure) => Set(configure, "shape"); - public QueryContainerDescriptor Shape(Action> configure) => Set(configure, "shape"); public QueryContainerDescriptor SimpleQueryString(SimpleQueryStringQuery simpleQueryStringQuery) => Set(simpleQueryStringQuery, "simple_query_string"); public QueryContainerDescriptor SimpleQueryString(Action configure) => Set(configure, "simple_query_string"); public QueryContainerDescriptor SimpleQueryString(Action> configure) => Set(configure, "simple_query_string"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeFieldQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeFieldQuery.g.cs deleted file mode 100644 index 270e955f106..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeFieldQuery.g.cs +++ /dev/null @@ -1,217 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. -// -// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ -// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ -// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ -// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ -// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ -// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ -// ------------------------------------------------ -// -// This file is automatically generated. -// Please do not edit these files manually. -// -// ------------------------------------------------ - -using Elastic.Clients.Elasticsearch.Fluent; -using Elastic.Clients.Elasticsearch.Serialization; -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Text.Json; -using System.Text.Json.Serialization; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.QueryDsl; -public sealed partial class ShapeFieldQuery : Query -{ - [JsonInclude] - [JsonPropertyName("indexed_shape")] - public Elastic.Clients.Elasticsearch.QueryDsl.FieldLookup? IndexedShape { get; set; } - - [JsonInclude] - [JsonPropertyName("relation")] - public Elastic.Clients.Elasticsearch.GeoShapeRelation? Relation { get; set; } - - [JsonInclude] - [JsonPropertyName("shape")] - public object? Shape { get; set; } -} - -public sealed partial class ShapeFieldQueryDescriptor : SerializableDescriptor> -{ - internal ShapeFieldQueryDescriptor(Action> configure) => configure.Invoke(this); - public ShapeFieldQueryDescriptor() : base() - { - } - - private Elastic.Clients.Elasticsearch.QueryDsl.FieldLookup? IndexedShapeValue { get; set; } - - private FieldLookupDescriptor IndexedShapeDescriptor { get; set; } - - private Action> IndexedShapeDescriptorAction { get; set; } - - private Elastic.Clients.Elasticsearch.GeoShapeRelation? RelationValue { get; set; } - - private object? ShapeValue { get; set; } - - public ShapeFieldQueryDescriptor IndexedShape(Elastic.Clients.Elasticsearch.QueryDsl.FieldLookup? indexedShape) - { - IndexedShapeDescriptor = null; - IndexedShapeDescriptorAction = null; - IndexedShapeValue = indexedShape; - return Self; - } - - public ShapeFieldQueryDescriptor IndexedShape(FieldLookupDescriptor descriptor) - { - IndexedShapeValue = null; - IndexedShapeDescriptorAction = null; - IndexedShapeDescriptor = descriptor; - return Self; - } - - public ShapeFieldQueryDescriptor IndexedShape(Action> configure) - { - IndexedShapeValue = null; - IndexedShapeDescriptor = null; - IndexedShapeDescriptorAction = configure; - return Self; - } - - public ShapeFieldQueryDescriptor Relation(Elastic.Clients.Elasticsearch.GeoShapeRelation? relation) - { - RelationValue = relation; - return Self; - } - - public ShapeFieldQueryDescriptor Shape(object? shape) - { - ShapeValue = shape; - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - writer.WriteStartObject(); - if (IndexedShapeDescriptor is not null) - { - writer.WritePropertyName("indexed_shape"); - JsonSerializer.Serialize(writer, IndexedShapeDescriptor, options); - } - else if (IndexedShapeDescriptorAction is not null) - { - writer.WritePropertyName("indexed_shape"); - JsonSerializer.Serialize(writer, new FieldLookupDescriptor(IndexedShapeDescriptorAction), options); - } - else if (IndexedShapeValue is not null) - { - writer.WritePropertyName("indexed_shape"); - JsonSerializer.Serialize(writer, IndexedShapeValue, options); - } - - if (RelationValue is not null) - { - writer.WritePropertyName("relation"); - JsonSerializer.Serialize(writer, RelationValue, options); - } - - if (ShapeValue is not null) - { - writer.WritePropertyName("shape"); - JsonSerializer.Serialize(writer, ShapeValue, options); - } - - writer.WriteEndObject(); - } -} - -public sealed partial class ShapeFieldQueryDescriptor : SerializableDescriptor -{ - internal ShapeFieldQueryDescriptor(Action configure) => configure.Invoke(this); - public ShapeFieldQueryDescriptor() : base() - { - } - - private Elastic.Clients.Elasticsearch.QueryDsl.FieldLookup? IndexedShapeValue { get; set; } - - private FieldLookupDescriptor IndexedShapeDescriptor { get; set; } - - private Action IndexedShapeDescriptorAction { get; set; } - - private Elastic.Clients.Elasticsearch.GeoShapeRelation? RelationValue { get; set; } - - private object? ShapeValue { get; set; } - - public ShapeFieldQueryDescriptor IndexedShape(Elastic.Clients.Elasticsearch.QueryDsl.FieldLookup? indexedShape) - { - IndexedShapeDescriptor = null; - IndexedShapeDescriptorAction = null; - IndexedShapeValue = indexedShape; - return Self; - } - - public ShapeFieldQueryDescriptor IndexedShape(FieldLookupDescriptor descriptor) - { - IndexedShapeValue = null; - IndexedShapeDescriptorAction = null; - IndexedShapeDescriptor = descriptor; - return Self; - } - - public ShapeFieldQueryDescriptor IndexedShape(Action configure) - { - IndexedShapeValue = null; - IndexedShapeDescriptor = null; - IndexedShapeDescriptorAction = configure; - return Self; - } - - public ShapeFieldQueryDescriptor Relation(Elastic.Clients.Elasticsearch.GeoShapeRelation? relation) - { - RelationValue = relation; - return Self; - } - - public ShapeFieldQueryDescriptor Shape(object? shape) - { - ShapeValue = shape; - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - writer.WriteStartObject(); - if (IndexedShapeDescriptor is not null) - { - writer.WritePropertyName("indexed_shape"); - JsonSerializer.Serialize(writer, IndexedShapeDescriptor, options); - } - else if (IndexedShapeDescriptorAction is not null) - { - writer.WritePropertyName("indexed_shape"); - JsonSerializer.Serialize(writer, new FieldLookupDescriptor(IndexedShapeDescriptorAction), options); - } - else if (IndexedShapeValue is not null) - { - writer.WritePropertyName("indexed_shape"); - JsonSerializer.Serialize(writer, IndexedShapeValue, options); - } - - if (RelationValue is not null) - { - writer.WritePropertyName("relation"); - JsonSerializer.Serialize(writer, RelationValue, options); - } - - if (ShapeValue is not null) - { - writer.WritePropertyName("shape"); - JsonSerializer.Serialize(writer, ShapeValue, options); - } - - writer.WriteEndObject(); - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs deleted file mode 100644 index 97f83af00f7..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs +++ /dev/null @@ -1,358 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. -// -// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ -// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ -// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ -// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ -// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ -// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ -// ------------------------------------------------ -// -// This file is automatically generated. -// Please do not edit these files manually. -// -// ------------------------------------------------ - -using Elastic.Clients.Elasticsearch.Fluent; -using Elastic.Clients.Elasticsearch.Serialization; -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Text.Json; -using System.Text.Json.Serialization; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed class ShapeQueryConverter : JsonConverter -{ - public override ShapeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new ShapeQuery(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) - { - var property = reader.GetString(); - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ignore_unmapped") - { - variant.IgnoreUnmapped = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Shape = JsonSerializer.Deserialize(ref reader, options); - } - } - - return variant; - } - - public override void Write(Utf8JsonWriter writer, ShapeQuery value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.Shape is not null) - { - if (!options.TryGetClientSettings(out var settings)) - { - throw new JsonException("Unable to retrive client settings for JsonSerializerOptions."); - } - - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Shape, options); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } - - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); - } - - writer.WriteEndObject(); - } -} - -[JsonConverter(typeof(ShapeQueryConverter))] -public sealed partial class ShapeQuery : Query -{ - public string? QueryName { get; set; } - - public float? Boost { get; set; } - - public Elastic.Clients.Elasticsearch.Field Field { get; set; } - - public bool? IgnoreUnmapped { get; set; } - - public Elastic.Clients.Elasticsearch.QueryDsl.ShapeFieldQuery Shape { get; set; } - - public static implicit operator QueryContainer(ShapeQuery shapeQuery) => QueryContainer.Shape(shapeQuery); -} - -public sealed partial class ShapeQueryDescriptor : SerializableDescriptor> -{ - internal ShapeQueryDescriptor(Action> configure) => configure.Invoke(this); - public ShapeQueryDescriptor() : base() - { - } - - private string? QueryNameValue { get; set; } - - private float? BoostValue { get; set; } - - private bool? IgnoreUnmappedValue { get; set; } - - private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } - - private Elastic.Clients.Elasticsearch.QueryDsl.ShapeFieldQuery ShapeValue { get; set; } - - private ShapeFieldQueryDescriptor ShapeDescriptor { get; set; } - - private Action> ShapeDescriptorAction { get; set; } - - public ShapeQueryDescriptor QueryName(string? queryName) - { - QueryNameValue = queryName; - return Self; - } - - public ShapeQueryDescriptor Boost(float? boost) - { - BoostValue = boost; - return Self; - } - - public ShapeQueryDescriptor IgnoreUnmapped(bool? ignoreUnmapped = true) - { - IgnoreUnmappedValue = ignoreUnmapped; - return Self; - } - - public ShapeQueryDescriptor Shape(Elastic.Clients.Elasticsearch.QueryDsl.ShapeFieldQuery shape) - { - ShapeValue = shape; - return Self; - } - - public ShapeQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) - { - FieldValue = field; - return Self; - } - - public ShapeQueryDescriptor Shape(ShapeFieldQueryDescriptor descriptor) - { - ShapeValue = null; - ShapeDescriptorAction = null; - ShapeDescriptor = descriptor; - return Self; - } - - public ShapeQueryDescriptor Shape(Action> configure) - { - ShapeValue = null; - ShapeDescriptor = null; - ShapeDescriptorAction = configure; - return Self; - } - - public ShapeQueryDescriptor Field(Expression> field) - { - FieldValue = field; - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - writer.WriteStartObject(); - if (FieldValue is not null && (ShapeValue is not null || ShapeDescriptor is not null || ShapeDescriptorAction is not null)) - { - var propertyName = settings.Inferrer.Field(FieldValue); - writer.WritePropertyName(propertyName); - if (ShapeValue is not null) - { - JsonSerializer.Serialize(writer, ShapeValue, options); - } - else if (ShapeDescriptor is not null) - { - JsonSerializer.Serialize(writer, ShapeDescriptor, options); - } - else if (ShapeDescriptorAction is not null) - { - var descriptor = new ShapeFieldQueryDescriptor(ShapeDescriptorAction); - JsonSerializer.Serialize(writer, descriptor, options); - } - } - - if (!string.IsNullOrEmpty(QueryNameValue)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(QueryNameValue); - } - - if (BoostValue.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(BoostValue.Value); - } - - if (IgnoreUnmappedValue.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(IgnoreUnmappedValue.Value); - } - - writer.WriteEndObject(); - } -} - -public sealed partial class ShapeQueryDescriptor : SerializableDescriptor -{ - internal ShapeQueryDescriptor(Action configure) => configure.Invoke(this); - public ShapeQueryDescriptor() : base() - { - } - - private string? QueryNameValue { get; set; } - - private float? BoostValue { get; set; } - - private bool? IgnoreUnmappedValue { get; set; } - - private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } - - private Elastic.Clients.Elasticsearch.QueryDsl.ShapeFieldQuery ShapeValue { get; set; } - - private ShapeFieldQueryDescriptor ShapeDescriptor { get; set; } - - private Action ShapeDescriptorAction { get; set; } - - public ShapeQueryDescriptor QueryName(string? queryName) - { - QueryNameValue = queryName; - return Self; - } - - public ShapeQueryDescriptor Boost(float? boost) - { - BoostValue = boost; - return Self; - } - - public ShapeQueryDescriptor IgnoreUnmapped(bool? ignoreUnmapped = true) - { - IgnoreUnmappedValue = ignoreUnmapped; - return Self; - } - - public ShapeQueryDescriptor Shape(Elastic.Clients.Elasticsearch.QueryDsl.ShapeFieldQuery shape) - { - ShapeValue = shape; - return Self; - } - - public ShapeQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) - { - FieldValue = field; - return Self; - } - - public ShapeQueryDescriptor Shape(ShapeFieldQueryDescriptor descriptor) - { - ShapeValue = null; - ShapeDescriptorAction = null; - ShapeDescriptor = descriptor; - return Self; - } - - public ShapeQueryDescriptor Shape(Action configure) - { - ShapeValue = null; - ShapeDescriptor = null; - ShapeDescriptorAction = configure; - return Self; - } - - public ShapeQueryDescriptor Field(Expression> field) - { - FieldValue = field; - return Self; - } - - public ShapeQueryDescriptor Field(Expression> field) - { - FieldValue = field; - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - writer.WriteStartObject(); - if (FieldValue is not null && (ShapeValue is not null || ShapeDescriptor is not null || ShapeDescriptorAction is not null)) - { - var propertyName = settings.Inferrer.Field(FieldValue); - writer.WritePropertyName(propertyName); - if (ShapeValue is not null) - { - JsonSerializer.Serialize(writer, ShapeValue, options); - } - else if (ShapeDescriptor is not null) - { - JsonSerializer.Serialize(writer, ShapeDescriptor, options); - } - else if (ShapeDescriptorAction is not null) - { - var descriptor = new ShapeFieldQueryDescriptor(ShapeDescriptorAction); - JsonSerializer.Serialize(writer, descriptor, options); - } - } - - if (!string.IsNullOrEmpty(QueryNameValue)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(QueryNameValue); - } - - if (BoostValue.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(BoostValue.Value); - } - - if (IgnoreUnmappedValue.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(IgnoreUnmappedValue.Value); - } - - writer.WriteEndObject(); - } -} \ No newline at end of file diff --git a/tests/Tests/Serialization/Queries/SearchSerializationTests.cs b/tests/Tests/Serialization/Queries/SearchSerializationTests.cs index b1233a7cda4..8e93a0be4e0 100644 --- a/tests/Tests/Serialization/Queries/SearchSerializationTests.cs +++ b/tests/Tests/Serialization/Queries/SearchSerializationTests.cs @@ -53,28 +53,4 @@ public async Task Search_WithTermsQuery_Serializes_ForDescriptor() await Verifier.VerifyJson(json); } - - [U] - public async Task Search_WithShapeQuery_Serializes_ForObjectInitializer() - { - var container = QueryContainer.Shape(new ShapeQuery - { - Field = Infer.Field(d => d.Description), - Shape = new ShapeFieldQuery - { - Relation = GeoShapeRelation.Within, - IndexedShape = new FieldLookup - { - Id = "deu", - Path = "location", - Index = "shapes" - } - }, - Boost = 1.2f - }); - - var json = SerializeAndGetJsonString(container); - - await Verifier.VerifyJson(json); - } }