From b40ae27df113a7838f6b21153b2b11cdd3b3e996 Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Thu, 29 Sep 2022 10:59:00 +0100 Subject: [PATCH] Query and Container API enhancements + bug fixes (#6676) * Incorporate latest code-gen changes * Bump SDK version * Updated query and container code gen * WIP non container fields * Complex query fixes * Update dependencies * Hide cachable expression property on field * Update intervals query test * Remove MGet tests which cause unit tests to hang. These need further review to understand the cause and resolve it so we can reintroduce them. * Support internals visible to on benchmarks * DescriptorValue prototypes * Query and container code gen improvements * Update test cases for intervals query serialise * Update exception message. * Improve container descriptor serialisation * Continue tests for intervals query * Update integration test matrix * Update container descriptor object variant storage + tests * Container serialization improvements and fixes * Improve container and field name query serialization * Final container converter serialization * WIP removal of variant interfaces * Fix internally tagged unions which require marker interfaces * Remove support for Migration APIs --- .ci/DockerFile | 2 +- .ci/make.sh | 2 +- .ci/readme.md | 2 +- .ci/run-repository.ps1 | 2 +- .ci/run-repository.sh | 2 +- .ci/run-tests.ps1 | 2 +- .ci/test-matrix.yml | 2 +- .github/workflows/integration-jobs.yml | 7 +- .github/workflows/make-bump.yml | 2 +- .github/workflows/make-release-notes.yml | 2 +- .github/workflows/stale-jobs.yml | 2 +- .github/workflows/test-jobs.yml | 4 +- .github/workflows/unified-release.yml | 2 +- benchmarks/Benchmarks/Benchmarks.csproj | 4 +- benchmarks/Benchmarks/Program.cs | 136 ++++ benchmarks/Benchmarks/packages.lock.json | 2 +- benchmarks/Profiling/packages.lock.json | 2 +- global.json | 2 +- .../packages.lock.json | 16 +- .../Common/Infer/Field/Field.cs | 2 +- .../Common/Query/Query.cs | 654 ++++++++++++++++-- .../Elastic.Clients.Elasticsearch.csproj | 1 + .../_Generated/Api/ApiUrlsLookup.g.cs | 3 - .../AsyncSearch/AsyncSearchSubmitRequest.g.cs | 60 +- .../_Generated/Api/Eql/EqlSearchRequest.g.cs | 14 +- .../_Generated/Api/FieldCapsRequest.g.cs | 14 +- .../IndexManagement/PutMappingRequest.g.cs | 14 +- .../MigrationDeprecationsRequest.g.cs | 88 --- .../MigrationDeprecationsResponse.g.cs | 43 -- ...grationGetFeatureUpgradeStatusRequest.g.cs | 53 -- ...rationGetFeatureUpgradeStatusResponse.g.cs | 35 - .../MigrationPostFeatureUpgradeResponse.g.cs | 35 - .../Api/Ml/MlPutDatafeedRequest.g.cs | 16 +- .../Api/Ml/MlPutDatafeedResponse.g.cs | 2 +- .../Api/Ml/MlUpdateDatafeedRequest.g.cs | 16 +- .../Api/Ml/MlUpdateDatafeedResponse.g.cs | 2 +- .../_Generated/Api/SearchRequest.g.cs | 60 +- .../Security/SecurityGetTokenResponse.g.cs | 2 +- .../_Generated/Api/Sql/SqlQueryRequest.g.cs | 14 +- .../Client/ElasticsearchClient.Migration.g.cs | 173 ----- .../Client/ElasticsearchClient.g.cs | 4 - .../DateHistogramAggregation.g.cs | 2 +- .../Aggregations/HistogramAggregation.g.cs | 2 +- .../InferenceConfigContainer.g.cs | 104 ++- .../Types/Aggregations/TermsAggregation.g.cs | 2 +- .../Analysis/IcuCollationTokenFilter.g.cs | 160 +++-- .../_Generated/Types/CompletionSuggester.g.cs | 2 +- .../Types/Enums/Enums.Migration.g.cs | 138 ---- .../_Generated/Types/ErrorCause.g.cs | 6 +- .../_Generated/Types/FieldSort.g.cs | 2 +- .../_Generated/Types/FieldSuggester.g.cs | 293 +++++--- .../_Generated/Types/GeoDistanceSort.g.cs | 2 +- .../Types/IndexManagement/AnalyzeToken.g.cs | 4 +- .../IndexManagement/IndexVersioning.g.cs | 26 +- .../Types/Ingest/AppendProcessor.g.cs | 2 +- .../Types/Ingest/AttachmentProcessor.g.cs | 2 +- .../Types/Ingest/BytesProcessor.g.cs | 2 +- .../Types/Ingest/CircleProcessor.g.cs | 2 +- .../Types/Ingest/ConvertProcessor.g.cs | 2 +- .../_Generated/Types/Ingest/CsvProcessor.g.cs | 2 +- .../Types/Ingest/DateIndexNameProcessor.g.cs | 2 +- .../Types/Ingest/DateProcessor.g.cs | 2 +- .../Types/Ingest/DissectProcessor.g.cs | 2 +- .../Types/Ingest/DotExpanderProcessor.g.cs | 2 +- .../Types/Ingest/DropProcessor.g.cs | 2 +- .../Types/Ingest/EnrichProcessor.g.cs | 2 +- .../Types/Ingest/FailProcessor.g.cs | 2 +- .../Types/Ingest/ForeachProcessor.g.cs | 2 +- .../Types/Ingest/GeoIpProcessor.g.cs | 2 +- .../Types/Ingest/GrokProcessor.g.cs | 2 +- .../Types/Ingest/GsubProcessor.g.cs | 2 +- .../Types/Ingest/InferenceConfig.g.cs | 106 ++- .../Ingest/InferenceConfigClassification.g.cs | 2 +- .../Ingest/InferenceConfigRegression.g.cs | 2 +- .../Types/Ingest/InferenceProcessor.g.cs | 2 +- .../Types/Ingest/JoinProcessor.g.cs | 2 +- .../Types/Ingest/JsonProcessor.g.cs | 2 +- .../Types/Ingest/KeyValueProcessor.g.cs | 2 +- .../Types/Ingest/LowercaseProcessor.g.cs | 2 +- .../Types/Ingest/PipelineProcessor.g.cs | 2 +- .../Types/Ingest/ProcessorContainer.g.cs | 138 ++-- .../Types/Ingest/RemoveProcessor.g.cs | 2 +- .../Types/Ingest/RenameProcessor.g.cs | 2 +- .../_Generated/Types/Ingest/SetProcessor.g.cs | 2 +- .../Ingest/SetSecurityUserProcessor.g.cs | 2 +- .../Types/Ingest/SortProcessor.g.cs | 2 +- .../Types/Ingest/SplitProcessor.g.cs | 2 +- .../Types/Ingest/TrimProcessor.g.cs | 2 +- .../Types/Ingest/UppercaseProcessor.g.cs | 2 +- .../Types/Ingest/UrlDecodeProcessor.g.cs | 2 +- .../Types/Ingest/UserAgentProcessor.g.cs | 2 +- .../Types/LaplaceSmoothingModel.g.cs | 2 +- .../LinearInterpolationSmoothingModel.g.cs | 2 +- .../Types/Migration/Deprecation.g.cs | 45 -- .../Types/Migration/MigrationFeature.g.cs | 33 - .../Migration/MigrationFeatureIndexInfo.g.cs | 41 -- .../Ml/ClassificationInferenceOptions.g.cs | 2 +- .../_Generated/Types/Ml/Datafeed.g.cs | 6 +- .../_Generated/Types/Ml/DatafeedConfig.g.cs | 16 +- .../Ml/DataframeAnalysisClassification.g.cs | 2 +- .../Types/Ml/DataframeAnalysisContainer.g.cs | 114 ++- .../Ml/DataframeAnalysisFeatureProcessor.g.cs | 132 ++-- ...ysisFeatureProcessorFrequencyEncoding.g.cs | 2 +- ...AnalysisFeatureProcessorMultiEncoding.g.cs | 2 +- ...AnalysisFeatureProcessorNGramEncoding.g.cs | 2 +- ...nalysisFeatureProcessorOneHotEncoding.g.cs | 2 +- ...sisFeatureProcessorTargetMeanEncoding.g.cs | 2 +- .../Ml/DataframeAnalysisOutlierDetection.g.cs | 2 +- .../Types/Ml/DataframeAnalysisRegression.g.cs | 2 +- .../Types/Ml/DataframeAnalyticsSource.g.cs | 14 +- .../Ml/DataframeEvaluationClassification.g.cs | 2 +- .../Ml/DataframeEvaluationContainer.g.cs | 116 ++-- .../DataframeEvaluationOutlierDetection.g.cs | 2 +- .../Ml/DataframeEvaluationRegression.g.cs | 2 +- .../Types/Ml/FillMaskInferenceOptions.g.cs | 2 +- .../Ml/FillMaskInferenceUpdateOptions.g.cs | 2 +- .../Ml/FrequencyEncodingPreprocessor.g.cs | 2 +- .../Ml/InferenceConfigCreateContainer.g.cs | 138 ++-- .../Ml/InferenceConfigUpdateContainer.g.cs | 138 ++-- .../Types/Ml/NerInferenceOptions.g.cs | 2 +- .../Types/Ml/NerInferenceUpdateOptions.g.cs | 2 +- .../Types/Ml/NlpBertTokenizationConfig.g.cs | 2 +- .../Ml/NlpRobertaTokenizationConfig.g.cs | 2 +- .../Types/Ml/OneHotEncodingPreprocessor.g.cs | 2 +- .../Types/Ml/PassThroughInferenceOptions.g.cs | 2 +- .../Ml/PassThroughInferenceUpdateOptions.g.cs | 2 +- .../_Generated/Types/Ml/Preprocessor.g.cs | 116 ++-- .../Ml/QuestionAnsweringInferenceOptions.g.cs | 2 +- ...estionAnsweringInferenceUpdateOptions.g.cs | 2 +- .../Types/Ml/RegressionInferenceOptions.g.cs | 2 +- .../Ml/TargetMeanEncodingPreprocessor.g.cs | 2 +- .../TextClassificationInferenceOptions.g.cs | 2 +- ...tClassificationInferenceUpdateOptions.g.cs | 2 +- .../Ml/TextEmbeddingInferenceOptions.g.cs | 2 +- .../TextEmbeddingInferenceUpdateOptions.g.cs | 2 +- .../Types/Ml/TokenizationConfigContainer.g.cs | 110 ++- ...> TrainedModelAssignmentRoutingTable.g.cs} | 10 +- .../Ml/TrainedModelDeploymentNodesStats.g.cs | 2 +- ...eroShotClassificationInferenceOptions.g.cs | 2 +- ...tClassificationInferenceUpdateOptions.g.cs | 2 +- .../_Generated/Types/MultisearchBody.g.cs | 58 +- .../_Generated/Types/PhraseSuggester.g.cs | 2 +- .../_Generated/Types/QueryDsl/BoolQuery.g.cs | 2 +- .../Types/QueryDsl/BoostingQuery.g.cs | 2 +- .../Types/QueryDsl/CombinedFieldsQuery.g.cs | 2 +- .../Types/QueryDsl/ConstantScoreQuery.g.cs | 2 +- .../Types/QueryDsl/DateRangeQuery.g.cs | 58 +- .../Types/QueryDsl/DisMaxQuery.g.cs | 2 +- .../Types/QueryDsl/ExistsQuery.g.cs | 2 +- .../FieldValueFactorScoreFunction.g.cs | 2 +- .../QueryDsl/FunctionScoreContainer.g.cs | 317 ++++++--- .../Types/QueryDsl/FunctionScoreQuery.g.cs | 2 +- .../_Generated/Types/QueryDsl/FuzzyQuery.g.cs | 58 +- .../Types/QueryDsl/GeoBoundingBoxQuery.g.cs | 2 +- .../Types/QueryDsl/GeoDistanceQuery.g.cs | 2 +- .../Types/QueryDsl/GeoPolygonQuery.g.cs | 2 +- .../Types/QueryDsl/GeoShapeQuery.g.cs | 2 +- .../Types/QueryDsl/HasChildQuery.g.cs | 2 +- .../Types/QueryDsl/HasParentQuery.g.cs | 2 +- .../_Generated/Types/QueryDsl/IdsQuery.g.cs | 2 +- .../Types/QueryDsl/IntervalsAllOf.g.cs | 2 +- .../Types/QueryDsl/IntervalsAnyOf.g.cs | 2 +- .../Types/QueryDsl/IntervalsContainer.g.cs | 136 ++-- .../Types/QueryDsl/IntervalsFilter.g.cs | 84 ++- .../Types/QueryDsl/IntervalsFuzzy.g.cs | 2 +- .../Types/QueryDsl/IntervalsMatch.g.cs | 2 +- .../Types/QueryDsl/IntervalsPrefix.g.cs | 2 +- .../Types/QueryDsl/IntervalsQuery.g.cs | 429 ++++++++---- .../Types/QueryDsl/IntervalsWildcard.g.cs | 2 +- .../_Generated/Types/QueryDsl/KnnQuery.g.cs | 211 ------ .../Types/QueryDsl/MatchAllQuery.g.cs | 2 +- .../Types/QueryDsl/MatchBoolPrefixQuery.g.cs | 58 +- .../Types/QueryDsl/MatchNoneQuery.g.cs | 2 +- .../QueryDsl/MatchPhrasePrefixQuery.g.cs | 58 +- .../Types/QueryDsl/MatchPhraseQuery.g.cs | 58 +- .../_Generated/Types/QueryDsl/MatchQuery.g.cs | 58 +- .../Types/QueryDsl/MoreLikeThisQuery.g.cs | 2 +- .../Types/QueryDsl/MultiMatchQuery.g.cs | 2 +- .../Types/QueryDsl/NestedQuery.g.cs | 2 +- .../Types/QueryDsl/NumberRangeQuery.g.cs | 58 +- .../Types/QueryDsl/ParentIdQuery.g.cs | 2 +- .../Types/QueryDsl/PercolateQuery.g.cs | 2 +- .../QueryDsl/PinnedDoc.g.cs} | 48 +- .../Types/QueryDsl/PinnedQuery.g.cs | 315 +++++++-- .../Types/QueryDsl/PrefixQuery.g.cs | 58 +- .../Types/QueryDsl/QueryContainer.g.cs | 217 +++--- .../Types/QueryDsl/QueryStringQuery.g.cs | 2 +- .../Types/QueryDsl/RandomScoreFunction.g.cs | 2 +- .../_Generated/Types/QueryDsl/RangeQuery.g.cs | 2 +- .../Types/QueryDsl/RankFeatureQuery.g.cs | 2 +- .../Types/QueryDsl/RegexpQuery.g.cs | 58 +- .../Types/QueryDsl/ScriptQuery.g.cs | 2 +- .../Types/QueryDsl/ScriptScoreFunction.g.cs | 2 +- .../Types/QueryDsl/ScriptScoreQuery.g.cs | 2 +- .../_Generated/Types/QueryDsl/ShapeQuery.g.cs | 2 +- .../QueryDsl/SimpleQueryStringQuery.g.cs | 2 +- .../Types/QueryDsl/SpanContainingQuery.g.cs | 2 +- .../Types/QueryDsl/SpanFieldMaskingQuery.g.cs | 2 +- .../Types/QueryDsl/SpanFirstQuery.g.cs | 2 +- .../Types/QueryDsl/SpanMultiTermQuery.g.cs | 2 +- .../Types/QueryDsl/SpanNearQuery.g.cs | 2 +- .../Types/QueryDsl/SpanNotQuery.g.cs | 2 +- .../Types/QueryDsl/SpanOrQuery.g.cs | 2 +- .../_Generated/Types/QueryDsl/SpanQuery.g.cs | 138 ++-- .../Types/QueryDsl/SpanTermQuery.g.cs | 58 +- .../Types/QueryDsl/SpanWithinQuery.g.cs | 2 +- .../_Generated/Types/QueryDsl/TermQuery.g.cs | 58 +- .../_Generated/Types/QueryDsl/TermsQuery.g.cs | 2 +- .../Types/QueryDsl/TermsSetQuery.g.cs | 58 +- .../Types/QueryDsl/WildcardQuery.g.cs | 58 +- .../Types/QueryDsl/WrapperQuery.g.cs | 2 +- .../_Generated/Types/ScoreSort.g.cs | 2 +- .../_Generated/Types/ScriptSort.g.cs | 2 +- .../Types/SmoothingModelContainer.g.cs | 110 ++- .../_Generated/Types/SortOptions.g.cs | 124 ++-- .../_Generated/Types/Source.g.cs | 14 +- .../Types/StupidBackoffSmoothingModel.g.cs | 2 +- .../_Generated/Types/TermSuggester.g.cs | 2 +- .../PivotGroupByContainer.g.cs | 116 ++-- .../TransformManagement/RetentionPolicy.g.cs | 2 +- .../RetentionPolicyContainer.g.cs | 96 ++- .../Types/TransformManagement/Source.g.cs | 14 +- .../TransformManagement/SyncContainer.g.cs | 96 ++- .../Types/TransformManagement/TimeSync.g.cs | 2 +- src/Playground/packages.lock.json | 6 +- .../Tests.ClusterLauncher/packages.lock.json | 228 +++--- tests/Tests.Configuration/tests.default.yaml | 2 +- tests/Tests.Core/Tests.Core.csproj | 2 +- tests/Tests.Core/packages.lock.json | 56 +- tests/Tests.Domain/packages.lock.json | 4 +- .../Aggregations/AggregationUsageTestBase.cs | 2 +- .../Multiple/MultiGet/MultiGetApiTests.cs | 121 ---- .../MultiSearch/MultiSearchApiTests.cs | 70 -- tests/Tests/Search/Count/CountApiTests.cs | 15 +- tests/Tests/Search/Search/SearchApiTests.cs | 6 +- .../Search/Search/SearchUsageTestBase.cs | 3 +- .../FieldNameQueryConverterTests.cs | 2 +- .../IntervalsQuerySerializationTests.cs | 87 +++ .../Queries/MultipleSearchFiltersTests.cs | 2 +- .../Queries/SearchSerializationTests.cs | 3 +- tests/Tests/Tests.csproj | 6 +- ...sQueryDescriptor_CanSerialize.verified.txt | 15 + ...anSerialize_WithObjectVariant.verified.txt | 15 + ...s.IntervalsQuery_CanSerialize.verified.txt | 15 + tests/Tests/packages.lock.json | 142 ++-- 245 files changed, 4348 insertions(+), 3495 deletions(-) delete mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationDeprecationsRequest.g.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationDeprecationsResponse.g.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationGetFeatureUpgradeStatusRequest.g.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationGetFeatureUpgradeStatusResponse.g.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationPostFeatureUpgradeResponse.g.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Migration.g.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Migration.g.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Types/Migration/Deprecation.g.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Types/Migration/MigrationFeature.g.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Types/Migration/MigrationFeatureIndexInfo.g.cs rename src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/{TrainedModelAllocationRoutingTable.g.cs => TrainedModelAssignmentRoutingTable.g.cs} (85%) delete mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/KnnQuery.g.cs rename src/Elastic.Clients.Elasticsearch/_Generated/{Api/Migration/MigrationPostFeatureUpgradeRequest.g.cs => Types/QueryDsl/PinnedDoc.g.cs} (55%) delete mode 100644 tests/Tests/Document/Multiple/MultiGet/MultiGetApiTests.cs delete mode 100644 tests/Tests/Document/Multiple/MultiSearch/MultiSearchApiTests.cs rename tests/Tests/Serialization/{ => Queries}/FieldNameQueryConverterTests.cs (96%) create mode 100644 tests/Tests/Serialization/Queries/IntervalsQuerySerializationTests.cs create mode 100644 tests/Tests/_VerifySnapshots/IntervalsQuerySerializationTests.IntervalsQueryDescriptor_CanSerialize.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/IntervalsQuerySerializationTests.IntervalsQueryDescriptor_CanSerialize_WithObjectVariant.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/IntervalsQuerySerializationTests.IntervalsQuery_CanSerialize.verified.txt diff --git a/.ci/DockerFile b/.ci/DockerFile index 39129427582..c0cfaa2750c 100644 --- a/.ci/DockerFile +++ b/.ci/DockerFile @@ -1,4 +1,4 @@ -ARG DOTNET_VERSION=6.0.300 +ARG DOTNET_VERSION=6.0.401 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 686ab41b67d..9172cf329a1 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.300} +DOTNET_VERSION=${DOTNET_VERSION-6.0.401} 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 08672c1802a..8c6c78c6ca6 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.300` | The .NET sdk version used to grab the proper container | +| `DOTNET_VERSION` | `6.0.401` | 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 c71508ed0e1..3d762cad534 100644 --- a/.ci/run-repository.ps1 +++ b/.ci/run-repository.ps1 @@ -14,7 +14,7 @@ param( $NODE_NAME, [string] - $DOTNET_VERSION = "6.0.300" + $DOTNET_VERSION = "6.0.401" ) $ESC = [char]27 diff --git a/.ci/run-repository.sh b/.ci/run-repository.sh index f3e61291aa1..bb2e51afd85 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.300} +DOTNET_VERSION=${DOTNET_VERSION-6.0.401} ELASTICSEARCH_URL=${ELASTICSEARCH_URL-"$elasticsearch_url"} elasticsearch_container=${elasticsearch_container-} diff --git a/.ci/run-tests.ps1 b/.ci/run-tests.ps1 index 8164b8fc236..9057f7b3b75 100644 --- a/.ci/run-tests.ps1 +++ b/.ci/run-tests.ps1 @@ -8,7 +8,7 @@ param ( $TEST_SUITE = "free", [string] - $DOTNET_VERSION = "6.0.300" + $DOTNET_VERSION = "6.0.401" ) $ESC = [char]27 diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml index d2e1ed3ad36..f9a850bee25 100755 --- a/.ci/test-matrix.yml +++ b/.ci/test-matrix.yml @@ -8,6 +8,6 @@ TEST_SUITE: - platinum DOTNET_VERSION: - - 6.0.300 + - 6.0.401 exclude: ~ diff --git a/.github/workflows/integration-jobs.yml b/.github/workflows/integration-jobs.yml index 825080b8884..476d69b43f9 100644 --- a/.github/workflows/integration-jobs.yml +++ b/.github/workflows/integration-jobs.yml @@ -24,8 +24,9 @@ jobs: stack_version: [ '8.1.3', '8.2.3', - '8.3.2', - '8.4.0-SNAPSHOT', + '8.3.3', + '8.4.2', + '8.5.0-SNAPSHOT', 'latest-8' ] @@ -34,7 +35,7 @@ jobs: uses: actions/checkout@v2 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.300' + dotnet-version: '6.0.401' - uses: actions/cache@v2 with: path: ~/.nuget/packages diff --git a/.github/workflows/make-bump.yml b/.github/workflows/make-bump.yml index e911f801800..7d02b394441 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.300' + dotnet-version: '6.0.401' - 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 84f6b1842a4..fd2acd38a8a 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.300' + dotnet-version: '6.0.401' - 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 1ad21d9bddd..b504f4f923b 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.300' + dotnet-version: '6.0.401' - uses: actions/cache@v2 with: path: ~/.nuget/packages diff --git a/.github/workflows/test-jobs.yml b/.github/workflows/test-jobs.yml index 7c2b97d6666..8c5ba564574 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.300' + dotnet-version: '6.0.401' - 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.300' + dotnet-version: '6.0.401' - uses: actions/cache@v2 with: path: ~/.nuget/packages diff --git a/.github/workflows/unified-release.yml b/.github/workflows/unified-release.yml index 491790f30f8..54f6a2f57d6 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.300' + dotnet-version: '6.0.401' - run: "./.ci/make.sh assemble ${{ matrix.stack_version }}" name: Assemble ${{ matrix.stack_version }} \ No newline at end of file diff --git a/benchmarks/Benchmarks/Benchmarks.csproj b/benchmarks/Benchmarks/Benchmarks.csproj index f114ee0dc51..c0d9345a5d7 100644 --- a/benchmarks/Benchmarks/Benchmarks.csproj +++ b/benchmarks/Benchmarks/Benchmarks.csproj @@ -5,6 +5,8 @@ net6.0 enable enable + True + $(SolutionRoot)\build\keys\keypair.snk @@ -12,7 +14,7 @@ - + diff --git a/benchmarks/Benchmarks/Program.cs b/benchmarks/Benchmarks/Program.cs index 804eee11019..0e1be799c90 100644 --- a/benchmarks/Benchmarks/Program.cs +++ b/benchmarks/Benchmarks/Program.cs @@ -8,10 +8,13 @@ using BenchmarkDotNet.Reports; using BenchmarkDotNet.Running; using Elastic.Clients.Elasticsearch; +using Elastic.Clients.Elasticsearch.Enrich; +using Elastic.Clients.Elasticsearch.QueryDsl; using Elastic.Transport; using Nest; using System.Globalization; using System.Text; +using Policy = Elastic.Clients.Elasticsearch.Enrich.Policy; var config = ManualConfig.Create(DefaultConfig.Instance); config.SummaryStyle = new SummaryStyle(CultureInfo.CurrentCulture, true, BenchmarkDotNet.Columns.SizeUnit.B, null); @@ -19,8 +22,141 @@ BenchmarkRunner.Run(config); +//var thing = new Benchmarks.DescriptorValues(); +//thing.Setup(); + +//var a = new EnrichPutPolicyRequestDescriptorV2("test"); + +//a.Match(new Policy { Name = "test-name" }); + +//var settings = new ElasticsearchClientSettings(); +//var serializer = new DefaultRequestResponseSerializer(settings); +//var stream = new MemoryStream(); + +//serializer.Serialize(a, stream); + +//stream.Position = 0; +//var sr = new StreamReader(stream); +//var result = sr.ReadToEnd(); + +//Console.ReadKey(); + namespace Benchmarks { + //public class DescriptorValues + //{ + // private EnrichPutPolicyRequestDescriptor? _data1; + // private EnrichPutPolicyRequestDescriptorV2? _data2; + // private EnrichPutPolicyRequestDescriptorV3? _data3; + // private EnrichPutPolicyRequestDescriptorV4? _data4; + + // //private Existing? _basicData1; + // //private NewV1? _basicData2; + // //private NewV2? _basicData3; + + // private readonly EnrichPutPolicyRequestDescriptor _existing = new("test"); + // private readonly EnrichPutPolicyRequestDescriptorV2 _newV1 = new("test"); + // private readonly EnrichPutPolicyRequestDescriptorV3 _newV2 = new("test"); + // private readonly EnrichPutPolicyRequestDescriptorV4 _newV3 = new("test"); + // private readonly Policy? _policy = new() { Name = "TEST" }; + + // private readonly EnrichPutPolicyRequestDescriptor _serializableExisting = new("test"); + // private readonly EnrichPutPolicyRequestDescriptorV2 _serializableNewV1 = new("test"); + // private readonly EnrichPutPolicyRequestDescriptorV3 _serializableNewV2 = new("test"); + // private readonly EnrichPutPolicyRequestDescriptorV4 _serializableNewV3 = new("test"); + + // private static readonly ElasticsearchClientSettings Settings = new(); + + // private readonly DefaultRequestResponseSerializer _serializer = new(Settings); + // private readonly MemoryStream _stream = new(); + + // [GlobalSetup] + // public void Setup() + // { + // _serializableExisting.GeoMatch(_policy); + // _serializableNewV1.GeoMatch(_policy); + // _serializableNewV2.GeoMatch(_policy); + // _serializableNewV3.GeoMatch(_policy); + // } + + // [Benchmark] + // public void Existing() => _data1 = new EnrichPutPolicyRequestDescriptor("name"); + + // [Benchmark] + // public void NewV1() => _data2 = new EnrichPutPolicyRequestDescriptorV2("name"); + + // [Benchmark] + // public void NewV2() => _data3 = new EnrichPutPolicyRequestDescriptorV3("name"); + + // [Benchmark] + // public void NewV3() => _data4 = new EnrichPutPolicyRequestDescriptorV4("name"); + + // //[Benchmark] + // //public void Existing() => _basicData1 = new Existing(); + + // //[Benchmark] + // //public void NewV1() => _basicData2 = new NewV1(); + + // //[Benchmark] + // //public void NewV2() => _basicData3 = new NewV2(); + + // [Benchmark] + // public void SetExisting() => _existing.GeoMatch(_policy); + + // [Benchmark] + // public void SetNewV1() => _newV1.GeoMatch(_policy); + + // [Benchmark] + // public void SetNewV2() => _newV2.GeoMatch(_policy); + + // [Benchmark] + // public void SetNewV3() => _newV3.GeoMatch(_policy); + + // [Benchmark] + // public void SerialiseExisting() + // { + // _stream.Position = 0; + // _serializer.Serialize(_serializableExisting, _stream); + // } + + // [Benchmark] + // public void SerialiseNewV1() + // { + // _stream.Position = 0; + // _serializer.Serialize(_serializableNewV1, _stream); + // } + + // [Benchmark] + // public void SerialiseNewV2() + // { + // _stream.Position = 0; + // _serializer.Serialize(_serializableNewV2, _stream); + // } + + // [Benchmark] + // public void SerialiseNewV3() + // { + // _stream.Position = 0; + // _serializer.Serialize(_serializableNewV3, _stream); + // } + //} + + // RESULT OF ABOVE: + //| Method | Mean [ns] | Error [ns] | StdDev [ns] | Gen 0 | Gen 1 | Allocated [B] | + //|------------------ |-----------:|-----------:|------------:|-------:|-------:|--------------:| + //| Existing | 116.408 ns | 2.1955 ns | 2.1563 ns | 0.0942 | 0.0002 | 592 B | + //| NewV1 | 113.021 ns | 1.8475 ns | 1.8145 ns | 0.0943 | 0.0004 | 592 B | + //| NewV2 | 115.728 ns | 2.2291 ns | 2.0851 ns | 0.0905 | 0.0002 | 568 B | + //| NewV3 | 112.813 ns | 2.2198 ns | 3.1118 ns | 0.0867 | 0.0002 | 544 B | + //| SetExisting | 1.688 ns | 0.0384 ns | 0.0340 ns | - | - | - | + //| SetNewV1 | 2.200 ns | 0.0232 ns | 0.0217 ns | - | - | - | + //| SetNewV2 | 2.555 ns | 0.0289 ns | 0.0256 ns | - | - | - | + //| SetNewV3 | 1.691 ns | 0.0306 ns | 0.0286 ns | - | - | - | + //| SerialiseExisting | 461.120 ns | 9.0066 ns | 8.4248 ns | 0.0687 | - | 432 B | + //| SerialiseNewV1 | 472.239 ns | 8.4655 ns | 7.9186 ns | 0.0687 | - | 432 B | + //| SerialiseNewV2 | 476.059 ns | 9.2350 ns | 10.2647 ns | 0.0687 | - | 432 B | + //| SerialiseNewV3 | 483.717 ns | 9.5424 ns | 8.9260 ns | 0.0687 | - | 432 B | + public class BulkIngest { //private static readonly List Data = Enumerable.Range(0, 100).Select(r => new SampleData()).ToList(); diff --git a/benchmarks/Benchmarks/packages.lock.json b/benchmarks/Benchmarks/packages.lock.json index 06f81800304..4cc00c45b55 100644 --- a/benchmarks/Benchmarks/packages.lock.json +++ b/benchmarks/Benchmarks/packages.lock.json @@ -1137,7 +1137,7 @@ "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } } } diff --git a/benchmarks/Profiling/packages.lock.json b/benchmarks/Profiling/packages.lock.json index 594338a452e..531acdead53 100644 --- a/benchmarks/Profiling/packages.lock.json +++ b/benchmarks/Profiling/packages.lock.json @@ -73,7 +73,7 @@ "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } } } diff --git a/global.json b/global.json index fb0dfbd3568..9e1c9458415 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.300", + "version": "6.0.401", "rollForward": "minor", "allowPrerelease": false }, diff --git a/src/Elastic.Clients.Elasticsearch.JsonNetSerializer/packages.lock.json b/src/Elastic.Clients.Elasticsearch.JsonNetSerializer/packages.lock.json index 2273acc692d..39e35a26455 100644 --- a/src/Elastic.Clients.Elasticsearch.JsonNetSerializer/packages.lock.json +++ b/src/Elastic.Clients.Elasticsearch.JsonNetSerializer/packages.lock.json @@ -105,7 +105,7 @@ "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } } }, @@ -256,7 +256,7 @@ "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } } }, @@ -516,9 +516,9 @@ "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2", - "System.Reflection.Emit": "4.3.0", - "System.Reflection.Emit.Lightweight": "4.3.0" + "Elastic.Transport": "[0.3.2, )", + "System.Reflection.Emit": "[4.3.0, )", + "System.Reflection.Emit.Lightweight": "[4.3.0, )" } } }, @@ -660,7 +660,7 @@ "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } } }, @@ -762,7 +762,7 @@ "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } } }, @@ -864,7 +864,7 @@ "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } } } diff --git a/src/Elastic.Clients.Elasticsearch/Common/Infer/Field/Field.cs b/src/Elastic.Clients.Elasticsearch/Common/Infer/Field/Field.cs index 8fbfbab995b..86e622fde8a 100644 --- a/src/Elastic.Clients.Elasticsearch/Common/Infer/Field/Field.cs +++ b/src/Elastic.Clients.Elasticsearch/Common/Infer/Field/Field.cs @@ -74,7 +74,7 @@ public Field(PropertyInfo property, double? boost = null, string format = null) public string? Format { get; set; } [JsonIgnore] - public bool CachableExpression { get; } + internal bool CachableExpression { get; } /// /// An expression from which the name of the field can be inferred diff --git a/src/Elastic.Clients.Elasticsearch/Common/Query/Query.cs b/src/Elastic.Clients.Elasticsearch/Common/Query/Query.cs index 550cd2a128b..6320a2b7ced 100644 --- a/src/Elastic.Clients.Elasticsearch/Common/Query/Query.cs +++ b/src/Elastic.Clients.Elasticsearch/Common/Query/Query.cs @@ -3,54 +3,628 @@ // See the LICENSE file in the project root for more information. using System; -using System.Text.Json.Serialization; +using System.IO; +using System.Text.Json; +using System.Text.RegularExpressions; +using Elastic.Clients.Elasticsearch.Enrich; +using Elastic.Transport; namespace Elastic.Clients.Elasticsearch.QueryDsl { - public interface IQuery - { - /// - /// Provides a boost to this query to influence its relevance score. - /// For example, a query with a boost of 2 is twice as important as a query with a boost of 1, - /// although the actual boost value that is applied undergoes normalization and internal optimization. - /// - //float? Boost { get; set; } // Was defined as a double before the code gen work - - ///// - ///// Whether the query is conditionless. A conditionless query is not serialized as part of the request - ///// sent to Elasticsearch. - ///// - //[JsonIgnore] - //bool Conditionless { get; } + //public interface IQuery + //{ + // /// + // /// Provides a boost to this query to influence its relevance score. + // /// For example, a query with a boost of 2 is twice as important as a query with a boost of 1, + // /// although the actual boost value that is applied undergoes normalization and internal optimization. + // /// + // //float? Boost { get; set; } // Was defined as a double before the code gen work - ///// - ///// Whether the query should be treated as strict. A strict query will throw an exception when serialized - ///// if it is . - ///// - //[JsonIgnore] - //bool IsStrict { get; set; } + // ///// + // ///// Whether the query is conditionless. A conditionless query is not serialized as part of the request + // ///// sent to Elasticsearch. + // ///// + // //[JsonIgnore] + // //bool Conditionless { get; } - ///// - ///// Whether the query should be treated as verbatim. A verbatim query will be serialized as part of the request, - ///// irrespective - ///// of whether it is or not. - ///// - //[JsonIgnore] - //bool IsVerbatim { get; set; } + // ///// + // ///// Whether the query should be treated as strict. A strict query will throw an exception when serialized + // ///// if it is . + // ///// + // //[JsonIgnore] + // //bool IsStrict { get; set; } - /// - /// Whether the query should be treated as writable. Used when determining how to combine queries. - /// - //[JsonIgnore] - //bool IsWritable { get; } + // ///// + // ///// Whether the query should be treated as verbatim. A verbatim query will be serialized as part of the request, + // ///// irrespective + // ///// of whether it is or not. + // ///// + // //[JsonIgnore] + // //bool IsVerbatim { get; set; } - /// - /// The name of the query. Allows you to retrieve for each document what part of the query it matched on. - /// - //string Name { get; set; } - } + // /// + // /// Whether the query should be treated as writable. Used when determining how to combine queries. + // /// + // //[JsonIgnore] + // //bool IsWritable { get; } + + // /// + // /// The name of the query. Allows you to retrieve for each document what part of the query it matched on. + // /// + // //string Name { get; set; } + //} + + //internal interface IFieldNameQueryDescriptor where T : Descriptor + //{ + // T Field(Field field); + //} + + //public partial class QueryContainerDescriptor + //{ + // private void Set(Action> descriptorAction, string variantName) + // where T : Descriptor, IFieldNameQueryDescriptor + // { + // if (ContainsVariant) + // throw new Exception("TODO"); + // ContainedVariantName = variantName; + // ContainsVariant = true; + // DescriptorType = typeof(T); + // var descriptor = (T)Activator.CreateInstance(typeof(T), true); + // descriptorAction?.Invoke(descriptor); + // Descriptor = descriptor; + // } + + // private void Set(Field field, Action> descriptorAction, string variantName) + // where T : Descriptor, IFieldNameQueryDescriptor + // { + // if (ContainsVariant) + // throw new Exception("TODO"); + // ContainedVariantName = variantName; + // ContainsVariant = true; + // DescriptorType = typeof(T); + // var descriptor = (T)Activator.CreateInstance(typeof(T), true); + // descriptor.Field(field); + // descriptorAction?.Invoke(descriptor); + // Descriptor = descriptor; + // } + //} + + // Leaving descriptor value experiments for future pick up work + + // RESULT OF EXPERIMENTS: + //| Method | Mean [ns] | Error [ns] | StdDev [ns] | Gen 0 | Gen 1 | Allocated [B] | + //|------------------ |-----------:|-----------:|------------:|-------:|-------:|--------------:| + //| Existing | 116.408 ns | 2.1955 ns | 2.1563 ns | 0.0942 | 0.0002 | 592 B | + //| NewV1 | 113.021 ns | 1.8475 ns | 1.8145 ns | 0.0943 | 0.0004 | 592 B | + //| NewV2 | 115.728 ns | 2.2291 ns | 2.0851 ns | 0.0905 | 0.0002 | 568 B | + //| NewV3 | 112.813 ns | 2.2198 ns | 3.1118 ns | 0.0867 | 0.0002 | 544 B | + //| SetExisting | 1.688 ns | 0.0384 ns | 0.0340 ns | - | - | - | + //| SetNewV1 | 2.200 ns | 0.0232 ns | 0.0217 ns | - | - | - | + //| SetNewV2 | 2.555 ns | 0.0289 ns | 0.0256 ns | - | - | - | + //| SetNewV3 | 1.691 ns | 0.0306 ns | 0.0286 ns | - | - | - | + //| SerialiseExisting | 461.120 ns | 9.0066 ns | 8.4248 ns | 0.0687 | - | 432 B | + //| SerialiseNewV1 | 472.239 ns | 8.4655 ns | 7.9186 ns | 0.0687 | - | 432 B | + //| SerialiseNewV2 | 476.059 ns | 9.2350 ns | 10.2647 ns | 0.0687 | - | 432 B | + //| SerialiseNewV3 | 483.717 ns | 9.5424 ns | 8.9260 ns | 0.0687 | - | 432 B | + + // We can save 16 bytes per descriptor property (when those properties themselves support descriptors). + // We would need to consider cases for types which do not have a descriptor and if we continue with a raw value property directly. + // This is probably the best choice. Performance for setting and serialising is generally on par. Serialisation for V3 is slower so + // is a trade off with the allocation reduction. Inlining may help there? + + //public sealed class Existing + //{ + // private Elastic.Clients.Elasticsearch.Enrich.Policy? GeoMatchValue { get; set; } + // private PolicyDescriptor GeoMatchDescriptor { get; set; } + // private Action> GeoMatchDescriptorAction { get; set; } + // private Elastic.Clients.Elasticsearch.Enrich.Policy? MatchValue { get; set; } + // private PolicyDescriptor MatchDescriptor { get; set; } + // private Action> MatchDescriptorAction { get; set; } + // private Elastic.Clients.Elasticsearch.Enrich.Policy? RangeValue { get; set; } + // private PolicyDescriptor RangeDescriptor { get; set; } + // private Action> RangeDescriptorAction { get; set; } + //} + + //public sealed class NewV1 + //{ + // private DescriptorValue> GeoMatchValue { get; set; } + // private DescriptorValue> MatchValue { get; set; } + // private DescriptorValue> RangeValue { get; set; } + //} + + //public sealed class NewV2 + //{ + // private DescriptorValueV2> GeoMatchValue { get; set; } + // private DescriptorValueV2> MatchValue { get; set; } + // private DescriptorValueV2> RangeValue { get; set; } + //} + + //public sealed partial class EnrichPutPolicyRequestDescriptorV2 : RequestDescriptorBase, EnrichPutPolicyRequestParameters> + //{ + // internal EnrichPutPolicyRequestDescriptorV2(Action> configure) => configure.Invoke(this); + + // public EnrichPutPolicyRequestDescriptorV2(Name name) : base(r => r.Required("name", name)) + // { + // } + + // internal EnrichPutPolicyRequestDescriptorV2() + // { + // } + + // internal override ApiUrls ApiUrls => ApiUrlsLookups.EnrichPutPolicy; + // protected override HttpMethod HttpMethod => HttpMethod.PUT; + // protected override bool SupportsBody => true; + + // public EnrichPutPolicyRequestDescriptorV2 Name(Name name) + // { + // RouteValues.Required("name", name); + // return Self; + // } + + // private DescriptorValue> GeoMatchValue { get; set; } = default; + // private DescriptorValue> MatchValue { get; set; } = default; + // private DescriptorValue> RangeValue { get; set; } = default; + + // public EnrichPutPolicyRequestDescriptorV2 GeoMatch(Policy? geoMatch) + // { + // GeoMatchValue = DescriptorValue>.Create(geoMatch); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV2 GeoMatch(PolicyDescriptor descriptor) + // { + // GeoMatchValue = DescriptorValue>.Create(descriptor); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV2 GeoMatch(Action> configure) + // { + // GeoMatchValue = DescriptorValue>.Create(configure); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV2 Match(Policy? match) + // { + // MatchValue = DescriptorValue>.Create(match); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV2 Match(PolicyDescriptor descriptor) + // { + // MatchValue = DescriptorValue>.Create(descriptor); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV2 Match(Action> configure) + // { + // MatchValue = DescriptorValue>.Create(configure); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV2 Range(Policy? range) + // { + // RangeValue = DescriptorValue>.Create(range); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV2 Range(PolicyDescriptor descriptor) + // { + // RangeValue = DescriptorValue>.Create(descriptor); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV2 Range(Action> configure) + // { + // RangeValue = DescriptorValue>.Create(configure); + // return Self; + // } + + // protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + // { + // writer.WriteStartObject(); + // GeoMatchValue.Serialize("geo_match", writer, options); + // MatchValue.Serialize("match", writer, options); + // RangeValue.Serialize("range", writer, options); + // writer.WriteEndObject(); + // } + //} + + //public sealed partial class EnrichPutPolicyRequestDescriptorV3 : RequestDescriptorBase, EnrichPutPolicyRequestParameters> + //{ + // internal EnrichPutPolicyRequestDescriptorV3(Action> configure) => configure.Invoke(this); + + // public EnrichPutPolicyRequestDescriptorV3(Name name) : base(r => r.Required("name", name)) + // { + // } + + // internal EnrichPutPolicyRequestDescriptorV3() + // { + // } + + // internal override ApiUrls ApiUrls => ApiUrlsLookups.EnrichPutPolicy; + // protected override HttpMethod HttpMethod => HttpMethod.PUT; + // protected override bool SupportsBody => true; + + // public EnrichPutPolicyRequestDescriptorV3 Name(Name name) + // { + // RouteValues.Required("name", name); + // return Self; + // } + + // private DescriptorValueV2> GeoMatchValue { get; set; } = default; + // private DescriptorValueV2> MatchValue { get; set; } = default; + // private DescriptorValueV2> RangeValue { get; set; } = default; + + // public EnrichPutPolicyRequestDescriptorV3 GeoMatch(Policy? geoMatch) + // { + // GeoMatchValue = DescriptorValueV2>.Create(geoMatch); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV3 GeoMatch(PolicyDescriptor descriptor) + // { + // GeoMatchValue = DescriptorValueV2>.Create(descriptor); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV3 GeoMatch(Action> configure) + // { + // GeoMatchValue = DescriptorValueV2>.Create(configure); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV3 Match(Policy? match) + // { + // MatchValue = DescriptorValueV2>.Create(match); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV3 Match(PolicyDescriptor descriptor) + // { + // MatchValue = DescriptorValueV2>.Create(descriptor); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV3 Match(Action> configure) + // { + // MatchValue = DescriptorValueV2>.Create(configure); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV3 Range(Policy? range) + // { + // RangeValue = DescriptorValueV2>.Create(range); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV3 Range(PolicyDescriptor descriptor) + // { + // RangeValue = DescriptorValueV2>.Create(descriptor); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV3 Range(Action> configure) + // { + // RangeValue = DescriptorValueV2>.Create(configure); + // return Self; + // } + + // protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + // { + // writer.WriteStartObject(); + // GeoMatchValue.Serialize("geo_match", writer, options); + // MatchValue.Serialize("geo_match", writer, options); + // RangeValue.Serialize("geo_match", writer, options); + // writer.WriteEndObject(); + // } + //} + + //public sealed partial class EnrichPutPolicyRequestDescriptorV4 : RequestDescriptorBase, EnrichPutPolicyRequestParameters> + //{ + // internal EnrichPutPolicyRequestDescriptorV4(Action> configure) => configure.Invoke(this); + + // public EnrichPutPolicyRequestDescriptorV4(Name name) : base(r => r.Required("name", name)) + // { + // } + + // internal EnrichPutPolicyRequestDescriptorV4() + // { + // } + + // internal override ApiUrls ApiUrls => ApiUrlsLookups.EnrichPutPolicy; + // protected override HttpMethod HttpMethod => HttpMethod.PUT; + // protected override bool SupportsBody => true; + + // public EnrichPutPolicyRequestDescriptorV4 Name(Name name) + // { + // RouteValues.Required("name", name); + // return Self; + // } + + // private DescriptorValueV3> GeoMatchValue { get; set; } = default; + // private DescriptorValueV3> MatchValue { get; set; } = default; + // private DescriptorValueV3> RangeValue { get; set; } = default; + + // public EnrichPutPolicyRequestDescriptorV4 GeoMatch(Policy? geoMatch) + // { + // GeoMatchValue = DescriptorValueV3>.Create(geoMatch); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV4 GeoMatch(PolicyDescriptor descriptor) + // { + // GeoMatchValue = DescriptorValueV3>.Create(descriptor); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV4 GeoMatch(Action> configure) + // { + // GeoMatchValue = DescriptorValueV3>.Create(configure); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV4 Match(Policy? match) + // { + // MatchValue = DescriptorValueV3>.Create(match); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV4 Match(PolicyDescriptor descriptor) + // { + // MatchValue = DescriptorValueV3>.Create(descriptor); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV4 Match(Action> configure) + // { + // MatchValue = DescriptorValueV3>.Create(configure); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV4 Range(Policy? range) + // { + // RangeValue = DescriptorValueV3>.Create(range); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV4 Range(PolicyDescriptor descriptor) + // { + // RangeValue = DescriptorValueV3>.Create(descriptor); + // return Self; + // } + + // public EnrichPutPolicyRequestDescriptorV4 Range(Action> configure) + // { + // RangeValue = DescriptorValueV3>.Create(configure); + // return Self; + // } + + // protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + // { + // writer.WriteStartObject(); + // GeoMatchValue.Serialize("geo_match", writer, options); + // MatchValue.Serialize("geo_match", writer, options); + // RangeValue.Serialize("geo_match", writer, options); + // writer.WriteEndObject(); + // } + //} + + //internal readonly struct DescriptorValue + // where TDescriptor : Descriptor + //{ + // private readonly TObject? _object; + // private readonly TDescriptor? _descriptor; + // private readonly Action? _descriptorAction; + // //private bool _isSet; + + // private DescriptorValue(TObject value) + // { + // _descriptor = null; + // _descriptorAction = null; + // _object = value; + // } + + // private DescriptorValue(TDescriptor value) + // { + // _descriptor = value; + // _descriptorAction = null; + // _object = default; + // } + + // private DescriptorValue(Action value) + // { + // _descriptor = null; + // _descriptorAction = value; + // _object = default; + // } + + // public static DescriptorValue Create(TObject value) + // => value switch + // { + // null => default, + // _ => new(value) + // }; + + // public static DescriptorValue Create(TDescriptor descriptor) + // => descriptor switch + // { + // null => default, + // _ => new(descriptor) + // }; + + // public static DescriptorValue Create(Action action) + // => action switch + // { + // null => default, + // _ => new(action) + // }; + + // public void Serialize(string propertyName, Utf8JsonWriter writer, JsonSerializerOptions options) + // { + // // We could include a ctor taking propertyName so we set it when initialising the property on descriptors? + + // //if (!_isSet) + // // return; + + // //writer.WritePropertyName(propertyName); + + // // Benchmark using a integer flag to know which value is set so we can avoid the null checks which "might" be faster. + + // if (_object is not null) + // { + // writer.WritePropertyName(propertyName); + // JsonSerializer.Serialize(writer, _object, options); + // } + // else if (_descriptor is not null) + // { + // writer.WritePropertyName(propertyName); + // JsonSerializer.Serialize(writer, _descriptor, options); + // } + // else if (_descriptorAction is not null) + // { + // writer.WritePropertyName(propertyName); + // var descriptor = (TDescriptor)Activator.CreateInstance(typeof(TDescriptor), true); + // _descriptorAction?.Invoke(descriptor); + // JsonSerializer.Serialize(writer, descriptor, options); + // } + // } + //} + + //internal readonly struct DescriptorValueV2 + // where TDescriptor : Descriptor + //{ + // private readonly object? _object; + // private readonly int _containedValueType; + + // private DescriptorValueV2(TObject value) + // { + // _object = value; + // _containedValueType = value is null ? 0 : 1; + // } + + // private DescriptorValueV2(TDescriptor value) + // { + // _object = value; + // _containedValueType = value is null ? 0 : 2; + // } + + // private DescriptorValueV2(Action value) + // { + // _object = value; + // _containedValueType = value is null ? 0 : 3; + // } + + // public static DescriptorValueV2 Create(TObject value) + // => value switch + // { + // null => default, + // _ => new(value) + // }; + + // public static DescriptorValueV2 Create(TDescriptor descriptor) + // => descriptor switch + // { + // null => default, + // _ => new(descriptor) + // }; + + // public static DescriptorValueV2 Create(Action action) + // => action switch + // { + // null => default, + // _ => new(action) + // }; + + // public void Serialize(string propertyName, Utf8JsonWriter writer, JsonSerializerOptions options) + // { + // // We could include a ctor taking propertyName so we set it when initialising the property on descriptors? + + // if (_containedValueType == 0) + // return; + + // writer.WritePropertyName(propertyName); + + // // Benchmark using a integer flag to know which value is set so we can avoid the null checks which "might" be faster. + + // switch (_containedValueType) + // { + // case 1: + // JsonSerializer.Serialize(writer, (TObject)_object, options); + // break; + // case 2: + // JsonSerializer.Serialize(writer, (TDescriptor)_object, options); + // break; + // case 3: + // var descriptor = (TDescriptor)Activator.CreateInstance(typeof(TDescriptor), true); + // ((Action)_object)?.Invoke(descriptor); + // JsonSerializer.Serialize(writer, descriptor, options); + // break; + // } + // } + //} + + //internal readonly struct DescriptorValueV3 + // where TDescriptor : Descriptor + //{ + // private readonly object? _object; + // // removing the int reduces the footprint but forces the use of type checking to perform operations + + // private DescriptorValueV3(TObject value) => _object = value; + + // private DescriptorValueV3(TDescriptor value) => _object = value; + + // private DescriptorValueV3(Action value) => _object = value; + + // public static DescriptorValueV3 Create(TObject value) + // => value switch + // { + // null => default, + // _ => new(value) + // }; + + // public static DescriptorValueV3 Create(TDescriptor descriptor) + // => descriptor switch + // { + // null => default, + // _ => new(descriptor) + // }; + + // public static DescriptorValueV3 Create(Action action) + // => action switch + // { + // null => default, + // _ => new(action) + // }; + + // public void Serialize(string propertyName, Utf8JsonWriter writer, JsonSerializerOptions options) + // { + // // We could include a ctor taking propertyName so we set it when initialising the property on descriptors? + + // if (_object is null) + // return; + + // writer.WritePropertyName(propertyName); + + // // Benchmark using a integer flag to know which value is set so we can avoid the null checks which "might" be faster. + + // if (_object is TObject value) + // { + // JsonSerializer.Serialize(writer, value, options); + // } + // else if (_object is TDescriptor descriptor) + // { + // JsonSerializer.Serialize(writer, descriptor, options); + // } + // else + // { + // var d = (TDescriptor)Activator.CreateInstance(typeof(TDescriptor), true); + // ((Action)_object)?.Invoke(d); + // JsonSerializer.Serialize(writer, d, options); + // } + // } + //} - public abstract partial class Query : IQuery + public abstract partial class Query //: IQuery { //[JsonIgnore] //public bool IsWritable => throw new NotImplementedException(); diff --git a/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj b/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj index 877361099ae..3504e0d01b6 100644 --- a/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj +++ b/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj @@ -28,6 +28,7 @@ + diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ApiUrlsLookup.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ApiUrlsLookup.g.cs index 6972c88dfbb..98b93dba421 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ApiUrlsLookup.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ApiUrlsLookup.g.cs @@ -156,9 +156,6 @@ internal static class ApiUrlsLookups internal static ApiUrls LicensePostStartTrial = new ApiUrls(new[] { "/_license/start_trial" }); internal static ApiUrls LogstashDeletePipeline = new ApiUrls(new[] { "/_logstash/pipeline/{id}" }); internal static ApiUrls LogstashPutPipeline = new ApiUrls(new[] { "/_logstash/pipeline/{id}" }); - internal static ApiUrls MigrationDeprecations = new ApiUrls(new[] { "/_migration/deprecations", "/{index}/_migration/deprecations" }); - internal static ApiUrls MigrationGetFeatureUpgradeStatus = new ApiUrls(new[] { "/_migration/system_features" }); - internal static ApiUrls MigrationPostFeatureUpgrade = new ApiUrls(new[] { "/_migration/system_features" }); internal static ApiUrls MachineLearningCloseJob = new ApiUrls(new[] { "/_ml/anomaly_detectors/{job_id}/_close" }); internal static ApiUrls MachineLearningDeleteCalendarEvent = new ApiUrls(new[] { "/_ml/calendars/{calendar_id}/events/{event_id}" }); internal static ApiUrls MachineLearningDeleteCalendar = new ApiUrls(new[] { "/_ml/calendars/{calendar_id}" }); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchSubmitRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchSubmitRequest.g.cs index f285242daa0..7ff17265fda 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchSubmitRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchSubmitRequest.g.cs @@ -154,6 +154,12 @@ public override AsyncSearchSubmitRequest Read(ref Utf8JsonReader reader, Type ty continue; } + if (property == "ext") + { + variant.Ext = JsonSerializer.Deserialize?>(ref reader, options); + continue; + } + if (property == "from") { variant.From = JsonSerializer.Deserialize(ref reader, options); @@ -306,7 +312,7 @@ public override AsyncSearchSubmitRequest Read(ref Utf8JsonReader reader, Type ty if (property == "runtime_mappings") { - variant.RuntimeMappings = JsonSerializer.Deserialize>?>(ref reader, options); + variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); continue; } @@ -342,6 +348,12 @@ public override void Write(Utf8JsonWriter writer, AsyncSearchSubmitRequest value writer.WriteBooleanValue(value.Explain.Value); } + if (value.Ext is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, value.Ext, options); + } + if (value.From.HasValue) { writer.WritePropertyName("from"); @@ -630,6 +642,10 @@ public AsyncSearchSubmitRequest(Elastic.Clients.Elasticsearch.Indices? indices) [JsonPropertyName("explain")] public bool? Explain { get; set; } + [JsonInclude] + [JsonPropertyName("ext")] + public Dictionary? Ext { get; set; } + [JsonInclude] [JsonPropertyName("from")] public int? From { get; set; } @@ -733,7 +749,7 @@ public AsyncSearchSubmitRequest(Elastic.Clients.Elasticsearch.Indices? indices) [JsonInclude] [JsonPropertyName("runtime_mappings")] - public Dictionary>? RuntimeMappings { get; set; } + public Dictionary? RuntimeMappings { get; set; } [JsonInclude] [JsonPropertyName("stats")] @@ -859,6 +875,8 @@ public AsyncSearchSubmitRequestDescriptor Indices(Elastic.Clients.Ela private bool? ExplainValue { get; set; } + private Dictionary? ExtValue { get; set; } + private int? FromValue { get; set; } private IEnumerable>? IndicesBoostValue { get; set; } @@ -873,7 +891,7 @@ public AsyncSearchSubmitRequestDescriptor Indices(Elastic.Clients.Ela private bool? ProfileValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private Dictionary? ScriptFieldsValue { get; set; } @@ -1169,6 +1187,12 @@ public AsyncSearchSubmitRequestDescriptor Explain(bool? explain = tru return Self; } + public AsyncSearchSubmitRequestDescriptor Ext(Func, FluentDictionary> selector) + { + ExtValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + public AsyncSearchSubmitRequestDescriptor From(int? from) { FromValue = from; @@ -1217,9 +1241,9 @@ public AsyncSearchSubmitRequestDescriptor Profile(bool? profile = tru return Self; } - public AsyncSearchSubmitRequestDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public AsyncSearchSubmitRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -1529,6 +1553,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteBooleanValue(ExplainValue.Value); } + if (ExtValue is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, ExtValue, options); + } + if (FromValue.HasValue) { writer.WritePropertyName("from"); @@ -1779,6 +1809,8 @@ public AsyncSearchSubmitRequestDescriptor Indices(Elastic.Clients.Elasticsearch. private bool? ExplainValue { get; set; } + private Dictionary? ExtValue { get; set; } + private int? FromValue { get; set; } private IEnumerable>? IndicesBoostValue { get; set; } @@ -1793,7 +1825,7 @@ public AsyncSearchSubmitRequestDescriptor Indices(Elastic.Clients.Elasticsearch. private bool? ProfileValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private Dictionary? ScriptFieldsValue { get; set; } @@ -2089,6 +2121,12 @@ public AsyncSearchSubmitRequestDescriptor Explain(bool? explain = true) return Self; } + public AsyncSearchSubmitRequestDescriptor Ext(Func, FluentDictionary> selector) + { + ExtValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + public AsyncSearchSubmitRequestDescriptor From(int? from) { FromValue = from; @@ -2137,9 +2175,9 @@ public AsyncSearchSubmitRequestDescriptor Profile(bool? profile = true) return Self; } - public AsyncSearchSubmitRequestDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public AsyncSearchSubmitRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -2455,6 +2493,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteBooleanValue(ExplainValue.Value); } + if (ExtValue is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, ExtValue, options); + } + if (FromValue.HasValue) { writer.WritePropertyName("from"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchRequest.g.cs index eeafc475fb3..8508057c0f4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchRequest.g.cs @@ -109,7 +109,7 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r [JsonInclude] [JsonPropertyName("runtime_mappings")] - public Dictionary>? RuntimeMappings { get; set; } + public Dictionary? RuntimeMappings { get; set; } } public sealed partial class EqlSearchRequestDescriptor : RequestDescriptorBase, EqlSearchRequestParameters> @@ -165,7 +165,7 @@ public EqlSearchRequestDescriptor Indices(Elastic.Clients.Elasticsear private Elastic.Clients.Elasticsearch.Eql.ResultPosition? ResultPositionValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private int? SizeValue { get; set; } @@ -295,9 +295,9 @@ public EqlSearchRequestDescriptor ResultPosition(Elastic.Clients.Elas return Self; } - public EqlSearchRequestDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public EqlSearchRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -527,7 +527,7 @@ public EqlSearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices private Elastic.Clients.Elasticsearch.Eql.ResultPosition? ResultPositionValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private int? SizeValue { get; set; } @@ -663,9 +663,9 @@ public EqlSearchRequestDescriptor ResultPosition(Elastic.Clients.Elasticsearch.E return Self; } - public EqlSearchRequestDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public EqlSearchRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs index dd1730d0215..c393d76d950 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs @@ -89,7 +89,7 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r [JsonInclude] [JsonPropertyName("runtime_mappings")] - public Dictionary>? RuntimeMappings { get; set; } + public Dictionary? RuntimeMappings { get; set; } } public sealed partial class FieldCapsRequestDescriptor : RequestDescriptorBase, FieldCapsRequestParameters> @@ -121,7 +121,7 @@ public FieldCapsRequestDescriptor Indices(Elastic.Clients.Elasticsear private Action> IndexFilterDescriptorAction { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } public FieldCapsRequestDescriptor IndexFilter(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? indexFilter) { @@ -147,9 +147,9 @@ public FieldCapsRequestDescriptor IndexFilter(Action RuntimeMappings(Func>, FluentDictionary>> selector) + public FieldCapsRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -211,7 +211,7 @@ public FieldCapsRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? private Action IndexFilterDescriptorAction { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } public FieldCapsRequestDescriptor IndexFilter(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? indexFilter) { @@ -237,9 +237,9 @@ public FieldCapsRequestDescriptor IndexFilter(Action>, FluentDictionary>> selector) + public FieldCapsRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingRequest.g.cs index 4ff5f6e4175..b6eadf99f24 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingRequest.g.cs @@ -115,7 +115,7 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r [JsonInclude] [JsonPropertyName("runtime")] - public Dictionary>? Runtime { get; set; } + public Dictionary? Runtime { get; set; } } public sealed partial class PutMappingRequestDescriptor : RequestDescriptorBase, PutMappingRequestParameters> @@ -176,7 +176,7 @@ public PutMappingRequestDescriptor Indices(Elastic.Clients.Elasticsea private Elastic.Clients.Elasticsearch.Mapping.Properties? PropertiesValue { get; set; } - private Dictionary>? RuntimeValue { get; set; } + private Dictionary? RuntimeValue { get; set; } public PutMappingRequestDescriptor FieldNames(Elastic.Clients.Elasticsearch.Mapping.FieldNamesField? fieldNames) { @@ -306,9 +306,9 @@ public PutMappingRequestDescriptor Properties(Action Runtime(Func>, FluentDictionary>> selector) + public PutMappingRequestDescriptor Runtime(Func, FluentDictionary> selector) { - RuntimeValue = selector?.Invoke(new FluentDictionary>()); + RuntimeValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -473,7 +473,7 @@ public PutMappingRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices private Elastic.Clients.Elasticsearch.Mapping.Properties? PropertiesValue { get; set; } - private Dictionary>? RuntimeValue { get; set; } + private Dictionary? RuntimeValue { get; set; } public PutMappingRequestDescriptor FieldNames(Elastic.Clients.Elasticsearch.Mapping.FieldNamesField? fieldNames) { @@ -603,9 +603,9 @@ public PutMappingRequestDescriptor Properties(Action>, FluentDictionary>> selector) + public PutMappingRequestDescriptor Runtime(Func, FluentDictionary> selector) { - RuntimeValue = selector?.Invoke(new FluentDictionary>()); + RuntimeValue = selector?.Invoke(new FluentDictionary()); return Self; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationDeprecationsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationDeprecationsRequest.g.cs deleted file mode 100644 index 295ff9e791a..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationDeprecationsRequest.g.cs +++ /dev/null @@ -1,88 +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.Transport; -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.Migration -{ - public sealed class MigrationDeprecationsRequestParameters : RequestParameters - { - } - - public sealed partial class MigrationDeprecationsRequest : PlainRequestBase - { - public MigrationDeprecationsRequest() - { - } - - public MigrationDeprecationsRequest(Elastic.Clients.Elasticsearch.IndexName? index) : base(r => r.Optional("index", index)) - { - } - - internal override ApiUrls ApiUrls => ApiUrlsLookups.MigrationDeprecations; - protected override HttpMethod HttpMethod => HttpMethod.GET; - protected override bool SupportsBody => false; - } - - public sealed partial class MigrationDeprecationsRequestDescriptor : RequestDescriptorBase, MigrationDeprecationsRequestParameters> - { - internal MigrationDeprecationsRequestDescriptor(Action> configure) => configure.Invoke(this); - public MigrationDeprecationsRequestDescriptor() - { - } - - internal override ApiUrls ApiUrls => ApiUrlsLookups.MigrationDeprecations; - protected override HttpMethod HttpMethod => HttpMethod.GET; - protected override bool SupportsBody => false; - public MigrationDeprecationsRequestDescriptor Index(Elastic.Clients.Elasticsearch.IndexName? index) - { - RouteValues.Optional("index", index); - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - } - } - - public sealed partial class MigrationDeprecationsRequestDescriptor : RequestDescriptorBase - { - internal MigrationDeprecationsRequestDescriptor(Action configure) => configure.Invoke(this); - public MigrationDeprecationsRequestDescriptor() - { - } - - internal override ApiUrls ApiUrls => ApiUrlsLookups.MigrationDeprecations; - protected override HttpMethod HttpMethod => HttpMethod.GET; - protected override bool SupportsBody => false; - public MigrationDeprecationsRequestDescriptor Index(Elastic.Clients.Elasticsearch.IndexName? index) - { - RouteValues.Optional("index", index); - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - } - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationDeprecationsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationDeprecationsResponse.g.cs deleted file mode 100644 index 05e12fd1eda..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationDeprecationsResponse.g.cs +++ /dev/null @@ -1,43 +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.Transport.Products.Elasticsearch; -using System.Collections.Generic; -using System.Text.Json.Serialization; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.Migration -{ - public sealed partial class MigrationDeprecationsResponse : ElasticsearchResponseBase - { - [JsonInclude] - [JsonPropertyName("cluster_settings")] - public IReadOnlyCollection ClusterSettings { get; init; } - - [JsonInclude] - [JsonPropertyName("index_settings")] - public Dictionary> IndexSettings { get; init; } - - [JsonInclude] - [JsonPropertyName("ml_settings")] - public IReadOnlyCollection MlSettings { get; init; } - - [JsonInclude] - [JsonPropertyName("node_settings")] - public IReadOnlyCollection NodeSettings { get; init; } - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationGetFeatureUpgradeStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationGetFeatureUpgradeStatusRequest.g.cs deleted file mode 100644 index e1ad2484ad4..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationGetFeatureUpgradeStatusRequest.g.cs +++ /dev/null @@ -1,53 +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.Transport; -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.Migration -{ - public sealed class MigrationGetFeatureUpgradeStatusRequestParameters : RequestParameters - { - } - - public sealed partial class MigrationGetFeatureUpgradeStatusRequest : PlainRequestBase - { - internal override ApiUrls ApiUrls => ApiUrlsLookups.MigrationGetFeatureUpgradeStatus; - protected override HttpMethod HttpMethod => HttpMethod.GET; - protected override bool SupportsBody => false; - } - - public sealed partial class MigrationGetFeatureUpgradeStatusRequestDescriptor : RequestDescriptorBase - { - internal MigrationGetFeatureUpgradeStatusRequestDescriptor(Action configure) => configure.Invoke(this); - public MigrationGetFeatureUpgradeStatusRequestDescriptor() - { - } - - internal override ApiUrls ApiUrls => ApiUrlsLookups.MigrationGetFeatureUpgradeStatus; - protected override HttpMethod HttpMethod => HttpMethod.GET; - protected override bool SupportsBody => false; - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - } - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationGetFeatureUpgradeStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationGetFeatureUpgradeStatusResponse.g.cs deleted file mode 100644 index 03110f3d769..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationGetFeatureUpgradeStatusResponse.g.cs +++ /dev/null @@ -1,35 +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.Transport.Products.Elasticsearch; -using System.Collections.Generic; -using System.Text.Json.Serialization; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.Migration -{ - public sealed partial class MigrationGetFeatureUpgradeStatusResponse : ElasticsearchResponseBase - { - [JsonInclude] - [JsonPropertyName("features")] - public IReadOnlyCollection Features { get; init; } - - [JsonInclude] - [JsonPropertyName("migration_status")] - public Elastic.Clients.Elasticsearch.Migration.MigrationStatus MigrationStatus { get; init; } - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationPostFeatureUpgradeResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationPostFeatureUpgradeResponse.g.cs deleted file mode 100644 index 8512c3215da..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationPostFeatureUpgradeResponse.g.cs +++ /dev/null @@ -1,35 +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.Transport.Products.Elasticsearch; -using System.Collections.Generic; -using System.Text.Json.Serialization; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.Migration -{ - public sealed partial class MigrationPostFeatureUpgradeResponse : ElasticsearchResponseBase - { - [JsonInclude] - [JsonPropertyName("accepted")] - public bool Accepted { get; init; } - - [JsonInclude] - [JsonPropertyName("features")] - public IReadOnlyCollection Features { get; init; } - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlPutDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlPutDatafeedRequest.g.cs index 4c178d663ca..32cfa74d2f0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlPutDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlPutDatafeedRequest.g.cs @@ -114,7 +114,7 @@ public override MlPutDatafeedRequest Read(ref Utf8JsonReader reader, Type typeTo if (property == "runtime_mappings") { - variant.RuntimeMappings = JsonSerializer.Deserialize>?>(ref reader, options); + variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); continue; } @@ -300,7 +300,7 @@ internal MlPutDatafeedRequest() [JsonInclude] [JsonPropertyName("runtime_mappings")] - public Dictionary>? RuntimeMappings { get; set; } + public Dictionary? RuntimeMappings { get; set; } [JsonInclude] [JsonPropertyName("script_fields")] @@ -377,7 +377,7 @@ public MlPutDatafeedRequestDescriptor DatafeedId(Elastic.Clients.Elas private Elastic.Clients.Elasticsearch.Duration? QueryDelayValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private Dictionary? ScriptFieldsValue { get; set; } @@ -521,9 +521,9 @@ public MlPutDatafeedRequestDescriptor QueryDelay(Elastic.Clients.Elas return Self; } - public MlPutDatafeedRequestDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public MlPutDatafeedRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -732,7 +732,7 @@ public MlPutDatafeedRequestDescriptor DatafeedId(Elastic.Clients.Elasticsearch.I private Elastic.Clients.Elasticsearch.Duration? QueryDelayValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private Dictionary? ScriptFieldsValue { get; set; } @@ -876,9 +876,9 @@ public MlPutDatafeedRequestDescriptor QueryDelay(Elastic.Clients.Elasticsearch.D return Self; } - public MlPutDatafeedRequestDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public MlPutDatafeedRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlPutDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlPutDatafeedResponse.g.cs index cbf9bbf4972..db617896ac3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlPutDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlPutDatafeedResponse.g.cs @@ -74,7 +74,7 @@ public sealed partial class MlPutDatafeedResponse : ElasticsearchResponseBase [JsonInclude] [JsonPropertyName("runtime_mappings")] - public Dictionary>? RuntimeMappings { get; init; } + public Dictionary? RuntimeMappings { get; init; } [JsonInclude] [JsonPropertyName("script_fields")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlUpdateDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlUpdateDatafeedRequest.g.cs index 55324716256..78d83e28a81 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlUpdateDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlUpdateDatafeedRequest.g.cs @@ -108,7 +108,7 @@ public override MlUpdateDatafeedRequest Read(ref Utf8JsonReader reader, Type typ if (property == "runtime_mappings") { - variant.RuntimeMappings = JsonSerializer.Deserialize>?>(ref reader, options); + variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); continue; } @@ -272,7 +272,7 @@ internal MlUpdateDatafeedRequest() [JsonInclude] [JsonPropertyName("runtime_mappings")] - public Dictionary>? RuntimeMappings { get; set; } + public Dictionary? RuntimeMappings { get; set; } [JsonInclude] [JsonPropertyName("script_fields")] @@ -341,7 +341,7 @@ public MlUpdateDatafeedRequestDescriptor DatafeedId(Elastic.Clients.E private Elastic.Clients.Elasticsearch.Duration? QueryDelayValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private Dictionary? ScriptFieldsValue { get; set; } @@ -473,9 +473,9 @@ public MlUpdateDatafeedRequestDescriptor QueryDelay(Elastic.Clients.E return Self; } - public MlUpdateDatafeedRequestDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public MlUpdateDatafeedRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -668,7 +668,7 @@ public MlUpdateDatafeedRequestDescriptor DatafeedId(Elastic.Clients.Elasticsearc private Elastic.Clients.Elasticsearch.Duration? QueryDelayValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private Dictionary? ScriptFieldsValue { get; set; } @@ -800,9 +800,9 @@ public MlUpdateDatafeedRequestDescriptor QueryDelay(Elastic.Clients.Elasticsearc return Self; } - public MlUpdateDatafeedRequestDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public MlUpdateDatafeedRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlUpdateDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlUpdateDatafeedResponse.g.cs index 0102fc6d1cf..fd296acc1fe 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlUpdateDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ml/MlUpdateDatafeedResponse.g.cs @@ -74,7 +74,7 @@ public sealed partial class MlUpdateDatafeedResponse : ElasticsearchResponseBase [JsonInclude] [JsonPropertyName("runtime_mappings")] - public Dictionary>? RuntimeMappings { get; init; } + public Dictionary? RuntimeMappings { get; init; } [JsonInclude] [JsonPropertyName("script_fields")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs index a0e5e605c8b..8a18760da05 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs @@ -145,6 +145,12 @@ public override SearchRequest Read(ref Utf8JsonReader reader, Type typeToConvert continue; } + if (property == "ext") + { + variant.Ext = JsonSerializer.Deserialize?>(ref reader, options); + continue; + } + if (property == "from") { variant.From = JsonSerializer.Deserialize(ref reader, options); @@ -297,7 +303,7 @@ public override SearchRequest Read(ref Utf8JsonReader reader, Type typeToConvert if (property == "runtime_mappings") { - variant.RuntimeMappings = JsonSerializer.Deserialize>?>(ref reader, options); + variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); continue; } @@ -333,6 +339,12 @@ public override void Write(Utf8JsonWriter writer, SearchRequest value, JsonSeria writer.WriteBooleanValue(value.Explain.Value); } + if (value.Ext is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, value.Ext, options); + } + if (value.From.HasValue) { writer.WritePropertyName("from"); @@ -612,6 +624,10 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => [JsonPropertyName("explain")] public bool? Explain { get; set; } + [JsonInclude] + [JsonPropertyName("ext")] + public Dictionary? Ext { get; set; } + [JsonInclude] [JsonPropertyName("from")] public int? From { get; set; } @@ -715,7 +731,7 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => [JsonInclude] [JsonPropertyName("runtime_mappings")] - public Dictionary>? RuntimeMappings { get; set; } + public Dictionary? RuntimeMappings { get; set; } [JsonInclude] [JsonPropertyName("stats")] @@ -842,6 +858,8 @@ public SearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch. private bool? ExplainValue { get; set; } + private Dictionary? ExtValue { get; set; } + private int? FromValue { get; set; } private IEnumerable>? IndicesBoostValue { get; set; } @@ -856,7 +874,7 @@ public SearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch. private bool? ProfileValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private Dictionary? ScriptFieldsValue { get; set; } @@ -1152,6 +1170,12 @@ public SearchRequestDescriptor Explain(bool? explain = true) return Self; } + public SearchRequestDescriptor Ext(Func, FluentDictionary> selector) + { + ExtValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + public SearchRequestDescriptor From(int? from) { FromValue = from; @@ -1200,9 +1224,9 @@ public SearchRequestDescriptor Profile(bool? profile = true) return Self; } - public SearchRequestDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public SearchRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -1512,6 +1536,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteBooleanValue(ExplainValue.Value); } + if (ExtValue is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, ExtValue, options); + } + if (FromValue.HasValue) { writer.WritePropertyName("from"); @@ -1763,6 +1793,8 @@ public SearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? in private bool? ExplainValue { get; set; } + private Dictionary? ExtValue { get; set; } + private int? FromValue { get; set; } private IEnumerable>? IndicesBoostValue { get; set; } @@ -1777,7 +1809,7 @@ public SearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? in private bool? ProfileValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private Dictionary? ScriptFieldsValue { get; set; } @@ -2073,6 +2105,12 @@ public SearchRequestDescriptor Explain(bool? explain = true) return Self; } + public SearchRequestDescriptor Ext(Func, FluentDictionary> selector) + { + ExtValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + public SearchRequestDescriptor From(int? from) { FromValue = from; @@ -2121,9 +2159,9 @@ public SearchRequestDescriptor Profile(bool? profile = true) return Self; } - public SearchRequestDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public SearchRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -2439,6 +2477,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteBooleanValue(ExplainValue.Value); } + if (ExtValue is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, ExtValue, options); + } + if (FromValue.HasValue) { writer.WritePropertyName("from"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SecurityGetTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SecurityGetTokenResponse.g.cs index 4added0a8b1..1e8aac95edd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SecurityGetTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SecurityGetTokenResponse.g.cs @@ -42,7 +42,7 @@ public sealed partial class SecurityGetTokenResponse : ElasticsearchResponseBase [JsonInclude] [JsonPropertyName("refresh_token")] - public string RefreshToken { get; init; } + public string? RefreshToken { get; init; } [JsonInclude] [JsonPropertyName("scope")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/SqlQueryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/SqlQueryRequest.g.cs index 501cf34d283..3e2f47bdad4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/SqlQueryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/SqlQueryRequest.g.cs @@ -76,7 +76,7 @@ public sealed partial class SqlQueryRequest : PlainRequestBase>? RuntimeMappings { get; set; } + public Dictionary? RuntimeMappings { get; set; } [JsonInclude] [JsonPropertyName("wait_for_completion_timeout")] @@ -139,7 +139,7 @@ public SqlQueryRequestDescriptor() private Elastic.Clients.Elasticsearch.Duration? RequestTimeoutValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private string? TimeZoneValue { get; set; } @@ -241,9 +241,9 @@ public SqlQueryRequestDescriptor RequestTimeout(Elastic.Clients.Elast return Self; } - public SqlQueryRequestDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public SqlQueryRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -412,7 +412,7 @@ public SqlQueryRequestDescriptor() private Elastic.Clients.Elasticsearch.Duration? RequestTimeoutValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private string? TimeZoneValue { get; set; } @@ -514,9 +514,9 @@ public SqlQueryRequestDescriptor RequestTimeout(Elastic.Clients.Elasticsearch.Du return Self; } - public SqlQueryRequestDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public SqlQueryRequestDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Migration.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Migration.g.cs deleted file mode 100644 index f272c6813dc..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Migration.g.cs +++ /dev/null @@ -1,173 +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 System; -using System.Threading; -using System.Threading.Tasks; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.Migration -{ - public class MigrationNamespace : NamespacedClientProxy - { - internal MigrationNamespace(ElasticsearchClient client) : base(client) - { - } - - public MigrationDeprecationsResponse Deprecations(MigrationDeprecationsRequest request) - { - request.BeforeRequest(); - return DoRequest(request); - } - - public Task DeprecationsAsync(MigrationDeprecationsRequest request, CancellationToken cancellationToken = default) - { - request.BeforeRequest(); - return DoRequestAsync(request, cancellationToken); - } - - public MigrationDeprecationsResponse Deprecations() - { - var descriptor = new MigrationDeprecationsRequestDescriptor(); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public MigrationDeprecationsResponse Deprecations(Action configureRequest) - { - var descriptor = new MigrationDeprecationsRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public MigrationDeprecationsResponse Deprecations(Action> configureRequest) - { - var descriptor = new MigrationDeprecationsRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequest, MigrationDeprecationsResponse>(descriptor); - } - - public Task DeprecationsAsync(CancellationToken cancellationToken = default) - { - var descriptor = new MigrationDeprecationsRequestDescriptor(); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - - public Task DeprecationsAsync(Action configureRequest, CancellationToken cancellationToken = default) - { - var descriptor = new MigrationDeprecationsRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - - public Task DeprecationsAsync(Action> configureRequest, CancellationToken cancellationToken = default) - { - var descriptor = new MigrationDeprecationsRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequestAsync, MigrationDeprecationsResponse>(descriptor); - } - - public MigrationGetFeatureUpgradeStatusResponse GetFeatureUpgradeStatus(MigrationGetFeatureUpgradeStatusRequest request) - { - request.BeforeRequest(); - return DoRequest(request); - } - - public Task GetFeatureUpgradeStatusAsync(MigrationGetFeatureUpgradeStatusRequest request, CancellationToken cancellationToken = default) - { - request.BeforeRequest(); - return DoRequestAsync(request, cancellationToken); - } - - public MigrationGetFeatureUpgradeStatusResponse GetFeatureUpgradeStatus() - { - var descriptor = new MigrationGetFeatureUpgradeStatusRequestDescriptor(); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public MigrationGetFeatureUpgradeStatusResponse GetFeatureUpgradeStatus(Action configureRequest) - { - var descriptor = new MigrationGetFeatureUpgradeStatusRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public Task GetFeatureUpgradeStatusAsync(CancellationToken cancellationToken = default) - { - var descriptor = new MigrationGetFeatureUpgradeStatusRequestDescriptor(); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - - public Task GetFeatureUpgradeStatusAsync(Action configureRequest, CancellationToken cancellationToken = default) - { - var descriptor = new MigrationGetFeatureUpgradeStatusRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - - public MigrationPostFeatureUpgradeResponse PostFeatureUpgrade(MigrationPostFeatureUpgradeRequest request) - { - request.BeforeRequest(); - return DoRequest(request); - } - - public Task PostFeatureUpgradeAsync(MigrationPostFeatureUpgradeRequest request, CancellationToken cancellationToken = default) - { - request.BeforeRequest(); - return DoRequestAsync(request, cancellationToken); - } - - public MigrationPostFeatureUpgradeResponse PostFeatureUpgrade() - { - var descriptor = new MigrationPostFeatureUpgradeRequestDescriptor(); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public MigrationPostFeatureUpgradeResponse PostFeatureUpgrade(Action configureRequest) - { - var descriptor = new MigrationPostFeatureUpgradeRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public Task PostFeatureUpgradeAsync(CancellationToken cancellationToken = default) - { - var descriptor = new MigrationPostFeatureUpgradeRequestDescriptor(); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - - public Task PostFeatureUpgradeAsync(Action configureRequest, CancellationToken cancellationToken = default) - { - var descriptor = new MigrationPostFeatureUpgradeRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs index 09b260ea21e..faf1184e2e2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs @@ -29,7 +29,6 @@ using Elastic.Clients.Elasticsearch.Ingest; using Elastic.Clients.Elasticsearch.License; using Elastic.Clients.Elasticsearch.Logstash; -using Elastic.Clients.Elasticsearch.Migration; using Elastic.Clients.Elasticsearch.Ml; using Elastic.Clients.Elasticsearch.Nodes; using Elastic.Clients.Elasticsearch.SearchableSnapshots; @@ -77,8 +76,6 @@ public partial class ElasticsearchClient public LogstashNamespace Logstash { get; private set; } - public MigrationNamespace Migration { get; private set; } - public MlNamespace Ml { get; private set; } public NodesNamespace Nodes { get; private set; } @@ -115,7 +112,6 @@ private partial void SetupNamespaces() Ingest = new IngestNamespace(this); License = new LicenseNamespace(this); Logstash = new LogstashNamespace(this); - Migration = new MigrationNamespace(this); Ml = new MlNamespace(this); Nodes = new NodesNamespace(this); SearchableSnapshots = new SearchableSnapshotsNamespace(this); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs index 8061e419890..deb39e5dde3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs @@ -293,7 +293,7 @@ public override void Write(Utf8JsonWriter writer, DateHistogramAggregation value } [JsonConverter(typeof(DateHistogramAggregationConverter))] - public sealed partial class DateHistogramAggregation : Aggregation, TransformManagement.IPivotGroupByVariant + public sealed partial class DateHistogramAggregation : Aggregation { public DateHistogramAggregation(string name) => Name = name; internal DateHistogramAggregation() diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs index 26d16d24f4a..5e911d64fe3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs @@ -239,7 +239,7 @@ public override void Write(Utf8JsonWriter writer, HistogramAggregation value, Js } [JsonConverter(typeof(HistogramAggregationConverter))] - public sealed partial class HistogramAggregation : Aggregation, TransformManagement.IPivotGroupByVariant + public sealed partial class HistogramAggregation : Aggregation { public HistogramAggregation(string name) => Name = name; internal HistogramAggregation() diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceConfigContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceConfigContainer.g.cs index 0fe520ab109..a98fd146322 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceConfigContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceConfigContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Aggregations { - public interface IInferenceConfigVariant - { - } - [JsonConverter(typeof(InferenceConfigContainerConverter))] public sealed partial class InferenceConfigContainer { - public InferenceConfigContainer(string variantName, IInferenceConfigVariant variant) + internal InferenceConfigContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public InferenceConfigContainer(string variantName, IInferenceConfigVariant vari Variant = variant; } - internal IInferenceConfigVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -63,7 +59,7 @@ public override InferenceConfigContainer Read(ref Utf8JsonReader reader, Type ty reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -110,38 +106,39 @@ public InferenceConfigContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal InferenceConfigContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the InferenceConfigContainerDescriptor. Only a single InferenceConfigContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IInferenceConfigVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new InferenceConfigContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the InferenceConfigContainerDescriptor. Only a single InferenceConfigContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Classification(Ml.ClassificationInferenceOptions variant) => Set(variant, "classification"); + public void Classification(Action configure) => Set(configure, "classification"); + public void Regression(Ml.RegressionInferenceOptions variant) => Set(variant, "regression"); + public void Regression(Action> configure) => Set(configure, "regression"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -150,22 +147,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Classification(Ml.ClassificationInferenceOptions variant) => Set(variant, "classification"); - public void Classification(Action configure) => Set(configure, "classification"); - public void Regression(Ml.RegressionInferenceOptions variant) => Set(variant, "regression"); - public void Regression(Action> configure) => Set(configure, "regression"); } public sealed partial class InferenceConfigContainerDescriptor : SerializableDescriptorBase @@ -175,38 +169,40 @@ public InferenceConfigContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal InferenceConfigContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the InferenceConfigContainerDescriptor. Only a single InferenceConfigContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IInferenceConfigVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new InferenceConfigContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the InferenceConfigContainerDescriptor. Only a single InferenceConfigContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Classification(Ml.ClassificationInferenceOptions variant) => Set(variant, "classification"); + public void Classification(Action configure) => Set(configure, "classification"); + public void Regression(Ml.RegressionInferenceOptions variant) => Set(variant, "regression"); + public void Regression(Action configure) => Set(configure, "regression"); + public void Regression(Action> configure) => Set(configure, "regression"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -215,22 +211,18 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Classification(Ml.ClassificationInferenceOptions variant) => Set(variant, "classification"); - public void Classification(Action configure) => Set(configure, "classification"); - public void Regression(Ml.RegressionInferenceOptions variant) => Set(variant, "regression"); - public void Regression(Action configure) => Set(configure, "regression"); - public void Regression(Action> configure) => Set(configure, "regression"); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs index 5296e6fd822..f23ebf0a160 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs @@ -365,7 +365,7 @@ public override void Write(Utf8JsonWriter writer, TermsAggregation value, JsonSe } [JsonConverter(typeof(TermsAggregationConverter))] - public sealed partial class TermsAggregation : Aggregation, TransformManagement.IPivotGroupByVariant + public sealed partial class TermsAggregation : Aggregation { public TermsAggregation(string name) => Name = name; internal TermsAggregation() diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IcuCollationTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IcuCollationTokenFilter.g.cs index e4007983504..15da660c335 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IcuCollationTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IcuCollationTokenFilter.g.cs @@ -28,39 +28,43 @@ public sealed partial class IcuCollationTokenFilter : ITokenFilterDefinition { [JsonInclude] [JsonPropertyName("alternate")] - public Elastic.Clients.Elasticsearch.Analysis.IcuCollationAlternate Alternate { get; set; } + public Elastic.Clients.Elasticsearch.Analysis.IcuCollationAlternate? Alternate { get; set; } [JsonInclude] [JsonPropertyName("caseFirst")] - public Elastic.Clients.Elasticsearch.Analysis.IcuCollationCaseFirst Casefirst { get; set; } + public Elastic.Clients.Elasticsearch.Analysis.IcuCollationCaseFirst? Casefirst { get; set; } [JsonInclude] [JsonPropertyName("caseLevel")] - public bool Caselevel { get; set; } + public bool? Caselevel { get; set; } [JsonInclude] [JsonPropertyName("country")] - public string Country { get; set; } + public string? Country { get; set; } [JsonInclude] [JsonPropertyName("decomposition")] - public Elastic.Clients.Elasticsearch.Analysis.IcuCollationDecomposition Decomposition { get; set; } + public Elastic.Clients.Elasticsearch.Analysis.IcuCollationDecomposition? Decomposition { get; set; } [JsonInclude] [JsonPropertyName("hiraganaQuaternaryMode")] - public bool Hiraganaquaternarymode { get; set; } + public bool? Hiraganaquaternarymode { get; set; } [JsonInclude] [JsonPropertyName("language")] - public string Language { get; set; } + public string? Language { get; set; } [JsonInclude] [JsonPropertyName("numeric")] - public bool Numeric { get; set; } + public bool? Numeric { get; set; } + + [JsonInclude] + [JsonPropertyName("rules")] + public string? Rules { get; set; } [JsonInclude] [JsonPropertyName("strength")] - public Elastic.Clients.Elasticsearch.Analysis.IcuCollationStrength Strength { get; set; } + public Elastic.Clients.Elasticsearch.Analysis.IcuCollationStrength? Strength { get; set; } [JsonInclude] [JsonPropertyName("type")] @@ -71,7 +75,7 @@ public sealed partial class IcuCollationTokenFilter : ITokenFilterDefinition [JsonInclude] [JsonPropertyName("variant")] - public string Variant { get; set; } + public string? Variant { get; set; } [JsonInclude] [JsonPropertyName("version")] @@ -85,79 +89,87 @@ public IcuCollationTokenFilterDescriptor() : base() { } - private Elastic.Clients.Elasticsearch.Analysis.IcuCollationAlternate AlternateValue { get; set; } + private Elastic.Clients.Elasticsearch.Analysis.IcuCollationAlternate? AlternateValue { get; set; } + + private Elastic.Clients.Elasticsearch.Analysis.IcuCollationCaseFirst? CasefirstValue { get; set; } - private Elastic.Clients.Elasticsearch.Analysis.IcuCollationCaseFirst CasefirstValue { get; set; } + private bool? CaselevelValue { get; set; } - private bool CaselevelValue { get; set; } + private string? CountryValue { get; set; } - private string CountryValue { get; set; } + private Elastic.Clients.Elasticsearch.Analysis.IcuCollationDecomposition? DecompositionValue { get; set; } - private Elastic.Clients.Elasticsearch.Analysis.IcuCollationDecomposition DecompositionValue { get; set; } + private bool? HiraganaquaternarymodeValue { get; set; } - private bool HiraganaquaternarymodeValue { get; set; } + private string? LanguageValue { get; set; } - private string LanguageValue { get; set; } + private bool? NumericValue { get; set; } - private bool NumericValue { get; set; } + private string? RulesValue { get; set; } - private Elastic.Clients.Elasticsearch.Analysis.IcuCollationStrength StrengthValue { get; set; } + private Elastic.Clients.Elasticsearch.Analysis.IcuCollationStrength? StrengthValue { get; set; } private string? VariabletopValue { get; set; } - private string VariantValue { get; set; } + private string? VariantValue { get; set; } private string? VersionValue { get; set; } - public IcuCollationTokenFilterDescriptor Alternate(Elastic.Clients.Elasticsearch.Analysis.IcuCollationAlternate alternate) + public IcuCollationTokenFilterDescriptor Alternate(Elastic.Clients.Elasticsearch.Analysis.IcuCollationAlternate? alternate) { AlternateValue = alternate; return Self; } - public IcuCollationTokenFilterDescriptor Casefirst(Elastic.Clients.Elasticsearch.Analysis.IcuCollationCaseFirst casefirst) + public IcuCollationTokenFilterDescriptor Casefirst(Elastic.Clients.Elasticsearch.Analysis.IcuCollationCaseFirst? casefirst) { CasefirstValue = casefirst; return Self; } - public IcuCollationTokenFilterDescriptor Caselevel(bool caselevel = true) + public IcuCollationTokenFilterDescriptor Caselevel(bool? caselevel = true) { CaselevelValue = caselevel; return Self; } - public IcuCollationTokenFilterDescriptor Country(string country) + public IcuCollationTokenFilterDescriptor Country(string? country) { CountryValue = country; return Self; } - public IcuCollationTokenFilterDescriptor Decomposition(Elastic.Clients.Elasticsearch.Analysis.IcuCollationDecomposition decomposition) + public IcuCollationTokenFilterDescriptor Decomposition(Elastic.Clients.Elasticsearch.Analysis.IcuCollationDecomposition? decomposition) { DecompositionValue = decomposition; return Self; } - public IcuCollationTokenFilterDescriptor Hiraganaquaternarymode(bool hiraganaquaternarymode = true) + public IcuCollationTokenFilterDescriptor Hiraganaquaternarymode(bool? hiraganaquaternarymode = true) { HiraganaquaternarymodeValue = hiraganaquaternarymode; return Self; } - public IcuCollationTokenFilterDescriptor Language(string language) + public IcuCollationTokenFilterDescriptor Language(string? language) { LanguageValue = language; return Self; } - public IcuCollationTokenFilterDescriptor Numeric(bool numeric = true) + public IcuCollationTokenFilterDescriptor Numeric(bool? numeric = true) { NumericValue = numeric; return Self; } - public IcuCollationTokenFilterDescriptor Strength(Elastic.Clients.Elasticsearch.Analysis.IcuCollationStrength strength) + public IcuCollationTokenFilterDescriptor Rules(string? rules) + { + RulesValue = rules; + return Self; + } + + public IcuCollationTokenFilterDescriptor Strength(Elastic.Clients.Elasticsearch.Analysis.IcuCollationStrength? strength) { StrengthValue = strength; return Self; @@ -169,7 +181,7 @@ public IcuCollationTokenFilterDescriptor Variabletop(string? variabletop) return Self; } - public IcuCollationTokenFilterDescriptor Variant(string variant) + public IcuCollationTokenFilterDescriptor Variant(string? variant) { VariantValue = variant; return Self; @@ -184,24 +196,66 @@ public IcuCollationTokenFilterDescriptor Version(string? version) protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { writer.WriteStartObject(); - writer.WritePropertyName("alternate"); - JsonSerializer.Serialize(writer, AlternateValue, options); - writer.WritePropertyName("caseFirst"); - JsonSerializer.Serialize(writer, CasefirstValue, options); - writer.WritePropertyName("caseLevel"); - writer.WriteBooleanValue(CaselevelValue); - writer.WritePropertyName("country"); - writer.WriteStringValue(CountryValue); - writer.WritePropertyName("decomposition"); - JsonSerializer.Serialize(writer, DecompositionValue, options); - writer.WritePropertyName("hiraganaQuaternaryMode"); - writer.WriteBooleanValue(HiraganaquaternarymodeValue); - writer.WritePropertyName("language"); - writer.WriteStringValue(LanguageValue); - writer.WritePropertyName("numeric"); - writer.WriteBooleanValue(NumericValue); - writer.WritePropertyName("strength"); - JsonSerializer.Serialize(writer, StrengthValue, options); + if (AlternateValue is not null) + { + writer.WritePropertyName("alternate"); + JsonSerializer.Serialize(writer, AlternateValue, options); + } + + if (CasefirstValue is not null) + { + writer.WritePropertyName("caseFirst"); + JsonSerializer.Serialize(writer, CasefirstValue, options); + } + + if (CaselevelValue.HasValue) + { + writer.WritePropertyName("caseLevel"); + writer.WriteBooleanValue(CaselevelValue.Value); + } + + if (!string.IsNullOrEmpty(CountryValue)) + { + writer.WritePropertyName("country"); + writer.WriteStringValue(CountryValue); + } + + if (DecompositionValue is not null) + { + writer.WritePropertyName("decomposition"); + JsonSerializer.Serialize(writer, DecompositionValue, options); + } + + if (HiraganaquaternarymodeValue.HasValue) + { + writer.WritePropertyName("hiraganaQuaternaryMode"); + writer.WriteBooleanValue(HiraganaquaternarymodeValue.Value); + } + + if (!string.IsNullOrEmpty(LanguageValue)) + { + writer.WritePropertyName("language"); + writer.WriteStringValue(LanguageValue); + } + + if (NumericValue.HasValue) + { + writer.WritePropertyName("numeric"); + writer.WriteBooleanValue(NumericValue.Value); + } + + if (!string.IsNullOrEmpty(RulesValue)) + { + writer.WritePropertyName("rules"); + writer.WriteStringValue(RulesValue); + } + + if (StrengthValue is not null) + { + writer.WritePropertyName("strength"); + JsonSerializer.Serialize(writer, StrengthValue, options); + } + writer.WritePropertyName("type"); writer.WriteStringValue("icu_collation"); if (!string.IsNullOrEmpty(VariabletopValue)) @@ -210,8 +264,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteStringValue(VariabletopValue); } - writer.WritePropertyName("variant"); - writer.WriteStringValue(VariantValue); + if (!string.IsNullOrEmpty(VariantValue)) + { + writer.WritePropertyName("variant"); + writer.WriteStringValue(VariantValue); + } + if (VersionValue is not null) { writer.WritePropertyName("version"); @@ -222,6 +280,6 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o } IcuCollationTokenFilter IBuildableDescriptor.Build() => new() - { Alternate = AlternateValue, Casefirst = CasefirstValue, Caselevel = CaselevelValue, Country = CountryValue, Decomposition = DecompositionValue, Hiraganaquaternarymode = HiraganaquaternarymodeValue, Language = LanguageValue, Numeric = NumericValue, Strength = StrengthValue, Variabletop = VariabletopValue, Variant = VariantValue, Version = VersionValue }; + { Alternate = AlternateValue, Casefirst = CasefirstValue, Caselevel = CaselevelValue, Country = CountryValue, Decomposition = DecompositionValue, Hiraganaquaternarymode = HiraganaquaternarymodeValue, Language = LanguageValue, Numeric = NumericValue, Rules = RulesValue, Strength = StrengthValue, Variabletop = VariabletopValue, Variant = VariantValue, Version = VersionValue }; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/CompletionSuggester.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/CompletionSuggester.g.cs index 88ccaad9df4..bf476da87c9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/CompletionSuggester.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/CompletionSuggester.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public sealed partial class CompletionSuggester : IFieldSuggesterVariant + public sealed partial class CompletionSuggester { [JsonInclude] [JsonPropertyName("analyzer")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Migration.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Migration.g.cs deleted file mode 100644 index dde8e9bc484..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Migration.g.cs +++ /dev/null @@ -1,138 +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 System; -using System.Text.Json; -using System.Text.Json.Serialization; -using System.Runtime.Serialization; -using Elastic.Transport; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.Migration -{ - [JsonConverter(typeof(DeprecationLevelConverter))] - public enum DeprecationLevel - { - [EnumMember(Value = "warning")] - Warning, - [EnumMember(Value = "none")] - None, - [EnumMember(Value = "info")] - Info, - [EnumMember(Value = "critical")] - Critical - } - - internal sealed class DeprecationLevelConverter : JsonConverter - { - public override DeprecationLevel Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var enumString = reader.GetString(); - switch (enumString) - { - case "warning": - return DeprecationLevel.Warning; - case "none": - return DeprecationLevel.None; - case "info": - return DeprecationLevel.Info; - case "critical": - return DeprecationLevel.Critical; - } - - ThrowHelper.ThrowJsonException(); - return default; - } - - public override void Write(Utf8JsonWriter writer, DeprecationLevel value, JsonSerializerOptions options) - { - switch (value) - { - case DeprecationLevel.Warning: - writer.WriteStringValue("warning"); - return; - case DeprecationLevel.None: - writer.WriteStringValue("none"); - return; - case DeprecationLevel.Info: - writer.WriteStringValue("info"); - return; - case DeprecationLevel.Critical: - writer.WriteStringValue("critical"); - return; - } - - writer.WriteNullValue(); - } - } - - [JsonConverter(typeof(MigrationStatusConverter))] - public enum MigrationStatus - { - [EnumMember(Value = "NO_MIGRATION_NEEDED")] - NoMigrationNeeded, - [EnumMember(Value = "MIGRATION_NEEDED")] - MigrationNeeded, - [EnumMember(Value = "IN_PROGRESS")] - InProgress, - [EnumMember(Value = "ERROR")] - Error - } - - internal sealed class MigrationStatusConverter : JsonConverter - { - public override MigrationStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var enumString = reader.GetString(); - switch (enumString) - { - case "NO_MIGRATION_NEEDED": - return MigrationStatus.NoMigrationNeeded; - case "MIGRATION_NEEDED": - return MigrationStatus.MigrationNeeded; - case "IN_PROGRESS": - return MigrationStatus.InProgress; - case "ERROR": - return MigrationStatus.Error; - } - - ThrowHelper.ThrowJsonException(); - return default; - } - - public override void Write(Utf8JsonWriter writer, MigrationStatus value, JsonSerializerOptions options) - { - switch (value) - { - case MigrationStatus.NoMigrationNeeded: - writer.WriteStringValue("NO_MIGRATION_NEEDED"); - return; - case MigrationStatus.MigrationNeeded: - writer.WriteStringValue("MIGRATION_NEEDED"); - return; - case MigrationStatus.InProgress: - writer.WriteStringValue("IN_PROGRESS"); - return; - case MigrationStatus.Error: - writer.WriteStringValue("ERROR"); - return; - } - - writer.WriteNullValue(); - } - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/ErrorCause.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/ErrorCause.g.cs index a4c9ecb40c1..9a25d87cbe0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/ErrorCause.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/ErrorCause.g.cs @@ -31,7 +31,7 @@ public override ErrorCause Read(ref Utf8JsonReader reader, Type typeToConvert, J if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); Elastic.Clients.Elasticsearch.ErrorCause? causedBy = default; - string reason = default; + string? reason = default; IReadOnlyCollection? rootCause = default; string? stackTrace = default; IReadOnlyCollection? suppressed = default; @@ -50,7 +50,7 @@ public override ErrorCause Read(ref Utf8JsonReader reader, Type typeToConvert, J if (property == "reason") { - reason = JsonSerializer.Deserialize(ref reader, options); + reason = JsonSerializer.Deserialize(ref reader, options); continue; } @@ -100,7 +100,7 @@ public sealed partial class ErrorCause public Dictionary Metadata { get; init; } - public string Reason { get; init; } + public string? Reason { get; init; } public IReadOnlyCollection? RootCause { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSort.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSort.g.cs index f608653da57..41c038fe0ad 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSort.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public sealed partial class FieldSort : ISortOptionsVariant + public sealed partial class FieldSort { [JsonInclude] [JsonPropertyName("format")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSuggester.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSuggester.g.cs index 5d7443758e1..025a2e8076a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSuggester.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSuggester.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public interface IFieldSuggesterVariant - { - } - [JsonConverter(typeof(FieldSuggesterConverter))] public sealed partial class FieldSuggester { - public FieldSuggester(string variantName, IFieldSuggesterVariant variant) + internal FieldSuggester(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public FieldSuggester(string variantName, IFieldSuggesterVariant variant) Variant = variant; } - internal IFieldSuggesterVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -72,41 +68,96 @@ public override FieldSuggester Read(ref Utf8JsonReader reader, Type typeToConver throw new JsonException("Expected start token."); } - reader.Read(); - if (reader.TokenType != JsonTokenType.PropertyName) + object? variantValue = default; + string? variantNameValue = default; + string? prefixValue = default; + string? regexValue = default; + string? textValue = default; + while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { - throw new JsonException("Expected property name token."); + if (reader.TokenType != JsonTokenType.PropertyName) + { + throw new JsonException("Expected a property name token."); + } + + if (reader.TokenType != JsonTokenType.PropertyName) + { + throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); + } + + var propertyName = reader.GetString(); + reader.Read(); + if (propertyName == "prefix") + { + prefixValue = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (propertyName == "regex") + { + regexValue = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (propertyName == "text") + { + textValue = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (propertyName == "completion") + { + variantValue = JsonSerializer.Deserialize(ref reader, options); + variantNameValue = propertyName; + continue; + } + + if (propertyName == "phrase") + { + variantValue = JsonSerializer.Deserialize(ref reader, options); + variantNameValue = propertyName; + continue; + } + + if (propertyName == "term") + { + variantValue = JsonSerializer.Deserialize(ref reader, options); + variantNameValue = propertyName; + continue; + } + + throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'FieldSuggester' from the response."); } - var propertyName = reader.GetString(); reader.Read(); - if (propertyName == "completion") + var result = new FieldSuggester(variantNameValue, variantValue); + result.Prefix = prefixValue; + result.Regex = regexValue; + result.Text = textValue; + return result; + } + + public override void Write(Utf8JsonWriter writer, FieldSuggester value, JsonSerializerOptions options) + { + writer.WriteStartObject(); + if (!string.IsNullOrEmpty(value.Prefix)) { - var variant = JsonSerializer.Deserialize(ref reader, options); - reader.Read(); - return new FieldSuggester(propertyName, variant); + writer.WritePropertyName("prefix"); + writer.WriteStringValue(value.Prefix); } - if (propertyName == "phrase") + if (!string.IsNullOrEmpty(value.Regex)) { - var variant = JsonSerializer.Deserialize(ref reader, options); - reader.Read(); - return new FieldSuggester(propertyName, variant); + writer.WritePropertyName("regex"); + writer.WriteStringValue(value.Regex); } - if (propertyName == "term") + if (!string.IsNullOrEmpty(value.Text)) { - var variant = JsonSerializer.Deserialize(ref reader, options); - reader.Read(); - return new FieldSuggester(propertyName, variant); + writer.WritePropertyName("text"); + writer.WriteStringValue(value.Text); } - throw new JsonException(); - } - - public override void Write(Utf8JsonWriter writer, FieldSuggester value, JsonSerializerOptions options) - { - writer.WriteStartObject(); writer.WritePropertyName(value.VariantName); switch (value.VariantName) { @@ -132,38 +183,65 @@ public FieldSuggesterDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal FieldSuggester Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the FieldSuggesterDescriptor. Only a single FieldSuggester variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IFieldSuggesterVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new FieldSuggester(variantName, variant); + throw new Exception("A variant has already been assigned to the FieldSuggesterDescriptor. Only a single FieldSuggester variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + private string? PrefixValue { get; set; } + + private string? RegexValue { get; set; } + + private string? TextValue { get; set; } + + public FieldSuggesterDescriptor Prefix(string? prefix) + { + PrefixValue = prefix; + return Self; + } + + public FieldSuggesterDescriptor Regex(string? regex) + { + RegexValue = regex; + return Self; + } + + public FieldSuggesterDescriptor Text(string? text) + { + TextValue = text; + return Self; + } + + public void Completion(CompletionSuggester variant) => Set(variant, "completion"); + public void Completion(Action> configure) => Set(configure, "completion"); + public void Phrase(PhraseSuggester variant) => Set(variant, "phrase"); + public void Phrase(Action> configure) => Set(configure, "phrase"); + public void Term(TermSuggester variant) => Set(variant, "term"); + public void Term(Action> configure) => Set(configure, "term"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -172,24 +250,37 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + if (!string.IsNullOrEmpty(PrefixValue)) { - JsonSerializer.Serialize(writer, Container, options); - return; + writer.WritePropertyName("prefix"); + writer.WriteStringValue(PrefixValue); + } + + if (!string.IsNullOrEmpty(RegexValue)) + { + writer.WritePropertyName("regex"); + writer.WriteStringValue(RegexValue); + } + + if (!string.IsNullOrEmpty(TextValue)) + { + writer.WritePropertyName("text"); + writer.WriteStringValue(TextValue); } - writer.WriteStartObject(); writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + writer.WriteEndObject(); } - - public void Completion(CompletionSuggester variant) => Set(variant, "completion"); - public void Completion(Action> configure) => Set(configure, "completion"); - public void Phrase(PhraseSuggester variant) => Set(variant, "phrase"); - public void Phrase(Action> configure) => Set(configure, "phrase"); - public void Term(TermSuggester variant) => Set(variant, "term"); - public void Term(Action> configure) => Set(configure, "term"); } public sealed partial class FieldSuggesterDescriptor : SerializableDescriptorBase @@ -199,56 +290,57 @@ public FieldSuggesterDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal FieldSuggester Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the FieldSuggesterDescriptor. Only a single FieldSuggester variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IFieldSuggesterVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new FieldSuggester(variantName, variant); + throw new Exception("A variant has already been assigned to the FieldSuggesterDescriptor. Only a single FieldSuggester variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + private string? PrefixValue { get; set; } + + private string? RegexValue { get; set; } + + private string? TextValue { get; set; } + + public FieldSuggesterDescriptor Prefix(string? prefix) { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } + PrefixValue = prefix; + return Self; + } - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } + public FieldSuggesterDescriptor Regex(string? regex) + { + RegexValue = regex; + return Self; + } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); + public FieldSuggesterDescriptor Text(string? text) + { + TextValue = text; + return Self; } public void Completion(CompletionSuggester variant) => Set(variant, "completion"); @@ -260,5 +352,44 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void Term(TermSuggester variant) => Set(variant, "term"); public void Term(Action configure) => Set(configure, "term"); public void Term(Action> configure) => Set(configure, "term"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + if (!string.IsNullOrEmpty(PrefixValue)) + { + writer.WritePropertyName("prefix"); + writer.WriteStringValue(PrefixValue); + } + + if (!string.IsNullOrEmpty(RegexValue)) + { + writer.WritePropertyName("regex"); + writer.WriteStringValue(RegexValue); + } + + if (!string.IsNullOrEmpty(TextValue)) + { + writer.WritePropertyName("text"); + writer.WriteStringValue(TextValue); + } + + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoDistanceSort.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoDistanceSort.g.cs index dbcead8ccd1..de4901c4951 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoDistanceSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoDistanceSort.g.cs @@ -125,7 +125,7 @@ public override void Write(Utf8JsonWriter writer, GeoDistanceSort value, JsonSer } [JsonConverter(typeof(GeoDistanceSortConverter))] - public sealed partial class GeoDistanceSort : ISortOptionsVariant + public sealed partial class GeoDistanceSort { public Elastic.Clients.Elasticsearch.GeoDistanceType? DistanceType { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AnalyzeToken.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AnalyzeToken.g.cs index c41e3734e1f..23327be0c5f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AnalyzeToken.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AnalyzeToken.g.cs @@ -35,8 +35,8 @@ public sealed partial class AnalyzeToken public long Position { get; init; } [JsonInclude] - [JsonPropertyName("position_length")] - public long? PositionLength { get; init; } + [JsonPropertyName("positionLength")] + public long? Positionlength { get; init; } [JsonInclude] [JsonPropertyName("start_offset")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexVersioning.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexVersioning.g.cs index 5e1aec16ea9..c53f471cdd3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexVersioning.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexVersioning.g.cs @@ -28,11 +28,7 @@ public sealed partial class IndexVersioning { [JsonInclude] [JsonPropertyName("created")] - public string Created { get; set; } - - [JsonInclude] - [JsonPropertyName("created_string")] - public string? CreatedString { get; set; } + public string? Created { get; set; } } public sealed partial class IndexVersioningDescriptor : SerializableDescriptorBase @@ -42,31 +38,21 @@ public IndexVersioningDescriptor() : base() { } - private string CreatedValue { get; set; } + private string? CreatedValue { get; set; } - private string? CreatedStringValue { get; set; } - - public IndexVersioningDescriptor Created(string created) + public IndexVersioningDescriptor Created(string? created) { CreatedValue = created; return Self; } - public IndexVersioningDescriptor CreatedString(string? createdString) - { - CreatedStringValue = createdString; - return Self; - } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { writer.WriteStartObject(); - writer.WritePropertyName("created"); - JsonSerializer.Serialize(writer, CreatedValue, options); - if (CreatedStringValue is not null) + if (CreatedValue is not null) { - writer.WritePropertyName("created_string"); - JsonSerializer.Serialize(writer, CreatedStringValue, options); + writer.WritePropertyName("created"); + JsonSerializer.Serialize(writer, CreatedValue, options); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AppendProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AppendProcessor.g.cs index 5eac649a541..0666348b619 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AppendProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AppendProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class AppendProcessor : IProcessorVariant + public sealed partial class AppendProcessor { [JsonInclude] [JsonPropertyName("allow_duplicates")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AttachmentProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AttachmentProcessor.g.cs index 7dd95e945eb..6d9a53341d9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AttachmentProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AttachmentProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class AttachmentProcessor : IProcessorVariant + public sealed partial class AttachmentProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/BytesProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/BytesProcessor.g.cs index ccfc4cfbaa6..c461e85a50f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/BytesProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/BytesProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class BytesProcessor : IProcessorVariant + public sealed partial class BytesProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CircleProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CircleProcessor.g.cs index 7c89c57e691..4df706cf0b7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CircleProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CircleProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class CircleProcessor : IProcessorVariant + public sealed partial class CircleProcessor { [JsonInclude] [JsonPropertyName("error_distance")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/ConvertProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/ConvertProcessor.g.cs index d00ceef5fd0..80fbc880524 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/ConvertProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/ConvertProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class ConvertProcessor : IProcessorVariant + public sealed partial class ConvertProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CsvProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CsvProcessor.g.cs index 13efef6d3ab..f6568c07085 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CsvProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CsvProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class CsvProcessor : IProcessorVariant + public sealed partial class CsvProcessor { [JsonInclude] [JsonPropertyName("description")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DateIndexNameProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DateIndexNameProcessor.g.cs index 2b3f712ec01..157abb67ae7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DateIndexNameProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DateIndexNameProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class DateIndexNameProcessor : IProcessorVariant + public sealed partial class DateIndexNameProcessor { [JsonInclude] [JsonPropertyName("date_formats")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DateProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DateProcessor.g.cs index 481719ac80b..38807dfb001 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DateProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DateProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class DateProcessor : IProcessorVariant + public sealed partial class DateProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DissectProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DissectProcessor.g.cs index ee936024a36..a6b57fcc8b9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DissectProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DissectProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class DissectProcessor : IProcessorVariant + public sealed partial class DissectProcessor { [JsonInclude] [JsonPropertyName("append_separator")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DotExpanderProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DotExpanderProcessor.g.cs index a9a44fba8a6..91ab754bd63 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DotExpanderProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DotExpanderProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class DotExpanderProcessor : IProcessorVariant + public sealed partial class DotExpanderProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DropProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DropProcessor.g.cs index 0ceaff18cd0..8b053e3b45f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DropProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DropProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class DropProcessor : IProcessorVariant + public sealed partial class DropProcessor { [JsonInclude] [JsonPropertyName("if")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/EnrichProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/EnrichProcessor.g.cs index 780a50593ff..249c0fe88c7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/EnrichProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/EnrichProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class EnrichProcessor : IProcessorVariant + public sealed partial class EnrichProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/FailProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/FailProcessor.g.cs index a67e78abea8..74569560f56 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/FailProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/FailProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class FailProcessor : IProcessorVariant + public sealed partial class FailProcessor { [JsonInclude] [JsonPropertyName("if")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/ForeachProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/ForeachProcessor.g.cs index 7cd4c206d7f..311da5f0c6e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/ForeachProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/ForeachProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class ForeachProcessor : IProcessorVariant + public sealed partial class ForeachProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/GeoIpProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/GeoIpProcessor.g.cs index 95e084cc4cb..e111b30d83d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/GeoIpProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/GeoIpProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class GeoIpProcessor : IProcessorVariant + public sealed partial class GeoIpProcessor { [JsonInclude] [JsonPropertyName("database_file")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/GrokProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/GrokProcessor.g.cs index 435608f6d9e..6fee15146ee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/GrokProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/GrokProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class GrokProcessor : IProcessorVariant + public sealed partial class GrokProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/GsubProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/GsubProcessor.g.cs index 1c222be3ed9..171a9524767 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/GsubProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/GsubProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class GsubProcessor : IProcessorVariant + public sealed partial class GsubProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfig.g.cs index 8c43dfdcc56..9f31214a26b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfig.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public interface IInferenceConfigVariant - { - } - [JsonConverter(typeof(InferenceConfigConverter))] public sealed partial class InferenceConfig { - public InferenceConfig(string variantName, IInferenceConfigVariant variant) + internal InferenceConfig(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public InferenceConfig(string variantName, IInferenceConfigVariant variant) Variant = variant; } - internal IInferenceConfigVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -63,7 +59,7 @@ public override InferenceConfig Read(ref Utf8JsonReader reader, Type typeToConve reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -110,38 +106,39 @@ public InferenceConfigDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal InferenceConfig Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the InferenceConfigDescriptor. Only a single InferenceConfig variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IInferenceConfigVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new InferenceConfig(variantName, variant); + throw new Exception("A variant has already been assigned to the InferenceConfigDescriptor. Only a single InferenceConfig variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Classification(InferenceConfigClassification variant) => Set(variant, "classification"); + public void Classification(Action> configure) => Set(configure, "classification"); + public void Regression(InferenceConfigRegression variant) => Set(variant, "regression"); + public void Regression(Action> configure) => Set(configure, "regression"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -150,22 +147,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Classification(InferenceConfigClassification variant) => Set(variant, "classification"); - public void Classification(Action> configure) => Set(configure, "classification"); - public void Regression(InferenceConfigRegression variant) => Set(variant, "regression"); - public void Regression(Action> configure) => Set(configure, "regression"); } public sealed partial class InferenceConfigDescriptor : SerializableDescriptorBase @@ -175,38 +169,41 @@ public InferenceConfigDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal InferenceConfig Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the InferenceConfigDescriptor. Only a single InferenceConfig variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IInferenceConfigVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new InferenceConfig(variantName, variant); + throw new Exception("A variant has already been assigned to the InferenceConfigDescriptor. Only a single InferenceConfig variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Classification(InferenceConfigClassification variant) => Set(variant, "classification"); + public void Classification(Action configure) => Set(configure, "classification"); + public void Classification(Action> configure) => Set(configure, "classification"); + public void Regression(InferenceConfigRegression variant) => Set(variant, "regression"); + public void Regression(Action configure) => Set(configure, "regression"); + public void Regression(Action> configure) => Set(configure, "regression"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -215,23 +212,18 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Classification(InferenceConfigClassification variant) => Set(variant, "classification"); - public void Classification(Action configure) => Set(configure, "classification"); - public void Classification(Action> configure) => Set(configure, "classification"); - public void Regression(InferenceConfigRegression variant) => Set(variant, "regression"); - public void Regression(Action configure) => Set(configure, "regression"); - public void Regression(Action> configure) => Set(configure, "regression"); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfigClassification.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfigClassification.g.cs index 2cdd6207b28..ff61ff55e1a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfigClassification.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfigClassification.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class InferenceConfigClassification : IInferenceConfigVariant + public sealed partial class InferenceConfigClassification { [JsonInclude] [JsonPropertyName("num_top_classes")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfigRegression.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfigRegression.g.cs index 46b856fe630..163ea15aa10 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfigRegression.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfigRegression.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class InferenceConfigRegression : IInferenceConfigVariant + public sealed partial class InferenceConfigRegression { [JsonInclude] [JsonPropertyName("num_top_feature_importance_values")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceProcessor.g.cs index ffbea7bcde2..79b82d11ffb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class InferenceProcessor : IProcessorVariant + public sealed partial class InferenceProcessor { [JsonInclude] [JsonPropertyName("field_map")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/JoinProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/JoinProcessor.g.cs index 64293219a3c..771bcd29bb2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/JoinProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/JoinProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class JoinProcessor : IProcessorVariant + public sealed partial class JoinProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/JsonProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/JsonProcessor.g.cs index 6995007913a..0bbd8f7737c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/JsonProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/JsonProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class JsonProcessor : IProcessorVariant + public sealed partial class JsonProcessor { [JsonInclude] [JsonPropertyName("add_to_root")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/KeyValueProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/KeyValueProcessor.g.cs index 71c83de36ae..e6b7f5110ff 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/KeyValueProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/KeyValueProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class KeyValueProcessor : IProcessorVariant + public sealed partial class KeyValueProcessor { [JsonInclude] [JsonPropertyName("exclude_keys")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/LowercaseProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/LowercaseProcessor.g.cs index 1caae89d3ff..8b3ef8d9dd8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/LowercaseProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/LowercaseProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class LowercaseProcessor : IProcessorVariant + public sealed partial class LowercaseProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/PipelineProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/PipelineProcessor.g.cs index 477b0617192..7c05ca1df44 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/PipelineProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/PipelineProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class PipelineProcessor : IProcessorVariant + public sealed partial class PipelineProcessor { [JsonInclude] [JsonPropertyName("if")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/ProcessorContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/ProcessorContainer.g.cs index 9bd7aa5fa3a..059a3e2d1c2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/ProcessorContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/ProcessorContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public interface IProcessorVariant - { - } - [JsonConverter(typeof(ProcessorContainerConverter))] public sealed partial class ProcessorContainer { - public ProcessorContainer(string variantName, IProcessorVariant variant) + internal ProcessorContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public ProcessorContainer(string variantName, IProcessorVariant variant) Variant = variant; } - internal IProcessorVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -94,7 +90,7 @@ public override ProcessorContainer Read(ref Utf8JsonReader reader, Type typeToCo reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -451,58 +447,35 @@ public ProcessorContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal ProcessorContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the ProcessorContainerDescriptor. Only a single ProcessorContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IProcessorVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new ProcessorContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the ProcessorContainerDescriptor. Only a single ProcessorContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } - - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } - - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); - } - public void Append(AppendProcessor variant) => Set(variant, "append"); public void Append(Action> configure) => Set(configure, "append"); public void Attachment(AttachmentProcessor variant) => Set(variant, "attachment"); @@ -569,6 +542,27 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void Urldecode(Action> configure) => Set(configure, "urldecode"); public void UserAgent(UserAgentProcessor variant) => Set(variant, "user_agent"); public void UserAgent(Action> configure) => Set(configure, "user_agent"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } public sealed partial class ProcessorContainerDescriptor : SerializableDescriptorBase @@ -578,58 +572,35 @@ public ProcessorContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal ProcessorContainer Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the ProcessorContainerDescriptor. Only a single ProcessorContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IProcessorVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new ProcessorContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the ProcessorContainerDescriptor. Only a single ProcessorContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } - - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } - - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); - } - public void Append(AppendProcessor variant) => Set(variant, "append"); public void Append(Action configure) => Set(configure, "append"); public void Append(Action> configure) => Set(configure, "append"); @@ -729,5 +700,26 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void UserAgent(UserAgentProcessor variant) => Set(variant, "user_agent"); public void UserAgent(Action configure) => Set(configure, "user_agent"); public void UserAgent(Action> configure) => Set(configure, "user_agent"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RemoveProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RemoveProcessor.g.cs index 11ef7c2a8fe..833e1d54a29 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RemoveProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RemoveProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class RemoveProcessor : IProcessorVariant + public sealed partial class RemoveProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RenameProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RenameProcessor.g.cs index 5a58fc780d8..146b002b451 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RenameProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RenameProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class RenameProcessor : IProcessorVariant + public sealed partial class RenameProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SetProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SetProcessor.g.cs index 51cb92bd887..d5a6b3b1a2c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SetProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SetProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class SetProcessor : IProcessorVariant + public sealed partial class SetProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SetSecurityUserProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SetSecurityUserProcessor.g.cs index 1ad8242c35d..74394e40b46 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SetSecurityUserProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SetSecurityUserProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class SetSecurityUserProcessor : IProcessorVariant + public sealed partial class SetSecurityUserProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SortProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SortProcessor.g.cs index 2905216e175..b949f89d01b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SortProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SortProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class SortProcessor : IProcessorVariant + public sealed partial class SortProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SplitProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SplitProcessor.g.cs index 4b000bbfb9f..68331b5557b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SplitProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/SplitProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class SplitProcessor : IProcessorVariant + public sealed partial class SplitProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/TrimProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/TrimProcessor.g.cs index 073c0e017d2..b113101df8b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/TrimProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/TrimProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class TrimProcessor : IProcessorVariant + public sealed partial class TrimProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/UppercaseProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/UppercaseProcessor.g.cs index 2adc27b0ba2..efe53d7473c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/UppercaseProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/UppercaseProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class UppercaseProcessor : IProcessorVariant + public sealed partial class UppercaseProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/UrlDecodeProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/UrlDecodeProcessor.g.cs index 906bb29b92a..90791131606 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/UrlDecodeProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/UrlDecodeProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class UrlDecodeProcessor : IProcessorVariant + public sealed partial class UrlDecodeProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/UserAgentProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/UserAgentProcessor.g.cs index 6d24624f442..c440972a749 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/UserAgentProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/UserAgentProcessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ingest { - public sealed partial class UserAgentProcessor : IProcessorVariant + public sealed partial class UserAgentProcessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/LaplaceSmoothingModel.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/LaplaceSmoothingModel.g.cs index c0544ed634c..3c3f13845ff 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/LaplaceSmoothingModel.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/LaplaceSmoothingModel.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public sealed partial class LaplaceSmoothingModel : ISmoothingModelVariant + public sealed partial class LaplaceSmoothingModel { [JsonInclude] [JsonPropertyName("alpha")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/LinearInterpolationSmoothingModel.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/LinearInterpolationSmoothingModel.g.cs index a8e51eb059d..86699dc5f7c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/LinearInterpolationSmoothingModel.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/LinearInterpolationSmoothingModel.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public sealed partial class LinearInterpolationSmoothingModel : ISmoothingModelVariant + public sealed partial class LinearInterpolationSmoothingModel { [JsonInclude] [JsonPropertyName("bigram_lambda")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Migration/Deprecation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Migration/Deprecation.g.cs deleted file mode 100644 index 4850843338e..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Migration/Deprecation.g.cs +++ /dev/null @@ -1,45 +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 System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Text.Json; -using System.Text.Json.Serialization; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.Migration -{ - public sealed partial class Deprecation - { - [JsonInclude] - [JsonPropertyName("details")] - public string Details { get; init; } - - [JsonInclude] - [JsonPropertyName("level")] - public Elastic.Clients.Elasticsearch.Migration.DeprecationLevel Level { get; init; } - - [JsonInclude] - [JsonPropertyName("message")] - public string Message { get; init; } - - [JsonInclude] - [JsonPropertyName("url")] - public string Url { get; init; } - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Migration/MigrationFeature.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Migration/MigrationFeature.g.cs deleted file mode 100644 index f5e97ebc285..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Migration/MigrationFeature.g.cs +++ /dev/null @@ -1,33 +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 System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Text.Json; -using System.Text.Json.Serialization; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.Migration -{ - public sealed partial class MigrationFeature - { - [JsonInclude] - [JsonPropertyName("feature_name")] - public string FeatureName { get; init; } - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Migration/MigrationFeatureIndexInfo.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Migration/MigrationFeatureIndexInfo.g.cs deleted file mode 100644 index d039214a1ad..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Migration/MigrationFeatureIndexInfo.g.cs +++ /dev/null @@ -1,41 +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 System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Text.Json; -using System.Text.Json.Serialization; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.Migration -{ - public sealed partial class MigrationFeatureIndexInfo - { - [JsonInclude] - [JsonPropertyName("failure_cause")] - public Elastic.Clients.Elasticsearch.ErrorCause? FailureCause { get; init; } - - [JsonInclude] - [JsonPropertyName("index")] - public string Index { get; init; } - - [JsonInclude] - [JsonPropertyName("version")] - public string Version { get; init; } - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/ClassificationInferenceOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/ClassificationInferenceOptions.g.cs index c34d4467548..136534446fa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/ClassificationInferenceOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/ClassificationInferenceOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class ClassificationInferenceOptions : Aggregations.IInferenceConfigVariant, IInferenceConfigCreateVariant, IInferenceConfigUpdateVariant + public sealed partial class ClassificationInferenceOptions { [JsonInclude] [JsonPropertyName("num_top_classes")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/Datafeed.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/Datafeed.g.cs index 90efe8af81a..ddd8e347bbb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/Datafeed.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/Datafeed.g.cs @@ -43,7 +43,7 @@ public override Datafeed Read(ref Utf8JsonReader reader, Type typeToConvert, Jso int? maxEmptySearches = default; Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer query = default; Elastic.Clients.Elasticsearch.Duration? queryDelay = default; - Dictionary>? runtimeMappings = default; + Dictionary? runtimeMappings = default; Dictionary? scriptFields = default; int? scrollSize = default; while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) @@ -131,7 +131,7 @@ public override Datafeed Read(ref Utf8JsonReader reader, Type typeToConvert, Jso if (property == "runtime_mappings") { - runtimeMappings = JsonSerializer.Deserialize>?>(ref reader, options); + runtimeMappings = JsonSerializer.Deserialize?>(ref reader, options); continue; } @@ -187,7 +187,7 @@ public sealed partial class Datafeed public Elastic.Clients.Elasticsearch.Duration? QueryDelay { get; init; } - public Dictionary>? RuntimeMappings { get; init; } + public Dictionary? RuntimeMappings { get; init; } public Dictionary? ScriptFields { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DatafeedConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DatafeedConfig.g.cs index b75a1e39ea1..95b98b934f8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DatafeedConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DatafeedConfig.g.cs @@ -110,7 +110,7 @@ public override DatafeedConfig Read(ref Utf8JsonReader reader, Type typeToConver if (property == "runtime_mappings") { - variant.RuntimeMappings = JsonSerializer.Deserialize>?>(ref reader, options); + variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); continue; } @@ -247,7 +247,7 @@ public sealed partial class DatafeedConfig public Elastic.Clients.Elasticsearch.Duration? QueryDelay { get; set; } - public Dictionary>? RuntimeMappings { get; set; } + public Dictionary? RuntimeMappings { get; set; } public Dictionary? ScriptFields { get; set; } @@ -301,7 +301,7 @@ public DatafeedConfigDescriptor() : base() private Elastic.Clients.Elasticsearch.Duration? QueryDelayValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private Dictionary? ScriptFieldsValue { get; set; } @@ -451,9 +451,9 @@ public DatafeedConfigDescriptor QueryDelay(Elastic.Clients.Elasticsea return Self; } - public DatafeedConfigDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public DatafeedConfigDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -649,7 +649,7 @@ public DatafeedConfigDescriptor() : base() private Elastic.Clients.Elasticsearch.Duration? QueryDelayValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private Dictionary? ScriptFieldsValue { get; set; } @@ -799,9 +799,9 @@ public DatafeedConfigDescriptor QueryDelay(Elastic.Clients.Elasticsearch.Duratio return Self; } - public DatafeedConfigDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public DatafeedConfigDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisClassification.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisClassification.g.cs index 1d790843279..9451515e440 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisClassification.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisClassification.g.cs @@ -285,7 +285,7 @@ public override void Write(Utf8JsonWriter writer, DataframeAnalysisClassificatio } [JsonConverter(typeof(DataframeAnalysisClassificationConverter))] - public sealed partial class DataframeAnalysisClassification : IDataframeAnalysisVariant + public sealed partial class DataframeAnalysisClassification { public double? Alpha { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisContainer.g.cs index 2480496b8c2..0c0da024dad 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public interface IDataframeAnalysisVariant - { - } - [JsonConverter(typeof(DataframeAnalysisContainerConverter))] public sealed partial class DataframeAnalysisContainer { - public DataframeAnalysisContainer(string variantName, IDataframeAnalysisVariant variant) + internal DataframeAnalysisContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public DataframeAnalysisContainer(string variantName, IDataframeAnalysisVariant Variant = variant; } - internal IDataframeAnalysisVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -64,7 +60,7 @@ public override DataframeAnalysisContainer Read(ref Utf8JsonReader reader, Type reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -121,38 +117,41 @@ public DataframeAnalysisContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal DataframeAnalysisContainer Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the DataframeAnalysisContainerDescriptor. Only a single DataframeAnalysisContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IDataframeAnalysisVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new DataframeAnalysisContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the DataframeAnalysisContainerDescriptor. Only a single DataframeAnalysisContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Classification(DataframeAnalysisClassification variant) => Set(variant, "classification"); + public void Classification(Action> configure) => Set(configure, "classification"); + public void OutlierDetection(DataframeAnalysisOutlierDetection variant) => Set(variant, "outlier_detection"); + public void OutlierDetection(Action configure) => Set(configure, "outlier_detection"); + public void Regression(DataframeAnalysisRegression variant) => Set(variant, "regression"); + public void Regression(Action> configure) => Set(configure, "regression"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -161,24 +160,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Classification(DataframeAnalysisClassification variant) => Set(variant, "classification"); - public void Classification(Action> configure) => Set(configure, "classification"); - public void OutlierDetection(DataframeAnalysisOutlierDetection variant) => Set(variant, "outlier_detection"); - public void OutlierDetection(Action configure) => Set(configure, "outlier_detection"); - public void Regression(DataframeAnalysisRegression variant) => Set(variant, "regression"); - public void Regression(Action> configure) => Set(configure, "regression"); } public sealed partial class DataframeAnalysisContainerDescriptor : SerializableDescriptorBase @@ -188,38 +182,43 @@ public DataframeAnalysisContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal DataframeAnalysisContainer Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the DataframeAnalysisContainerDescriptor. Only a single DataframeAnalysisContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IDataframeAnalysisVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new DataframeAnalysisContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the DataframeAnalysisContainerDescriptor. Only a single DataframeAnalysisContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Classification(DataframeAnalysisClassification variant) => Set(variant, "classification"); + public void Classification(Action configure) => Set(configure, "classification"); + public void Classification(Action> configure) => Set(configure, "classification"); + public void OutlierDetection(DataframeAnalysisOutlierDetection variant) => Set(variant, "outlier_detection"); + public void OutlierDetection(Action configure) => Set(configure, "outlier_detection"); + public void Regression(DataframeAnalysisRegression variant) => Set(variant, "regression"); + public void Regression(Action configure) => Set(configure, "regression"); + public void Regression(Action> configure) => Set(configure, "regression"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -228,25 +227,18 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Classification(DataframeAnalysisClassification variant) => Set(variant, "classification"); - public void Classification(Action configure) => Set(configure, "classification"); - public void Classification(Action> configure) => Set(configure, "classification"); - public void OutlierDetection(DataframeAnalysisOutlierDetection variant) => Set(variant, "outlier_detection"); - public void OutlierDetection(Action configure) => Set(configure, "outlier_detection"); - public void Regression(DataframeAnalysisRegression variant) => Set(variant, "regression"); - public void Regression(Action configure) => Set(configure, "regression"); - public void Regression(Action> configure) => Set(configure, "regression"); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessor.g.cs index 6d6ab1d4a34..ee6476a5c94 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessor.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public interface IDataframeAnalysisFeatureProcessorVariant - { - } - [JsonConverter(typeof(DataframeAnalysisFeatureProcessorConverter))] public sealed partial class DataframeAnalysisFeatureProcessor { - public DataframeAnalysisFeatureProcessor(string variantName, IDataframeAnalysisFeatureProcessorVariant variant) + internal DataframeAnalysisFeatureProcessor(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public DataframeAnalysisFeatureProcessor(string variantName, IDataframeAnalysisF Variant = variant; } - internal IDataframeAnalysisFeatureProcessorVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -66,7 +62,7 @@ public override DataframeAnalysisFeatureProcessor Read(ref Utf8JsonReader reader reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -143,38 +139,45 @@ public DataframeAnalysisFeatureProcessorDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal DataframeAnalysisFeatureProcessor Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the DataframeAnalysisFeatureProcessorDescriptor. Only a single DataframeAnalysisFeatureProcessor variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IDataframeAnalysisFeatureProcessorVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new DataframeAnalysisFeatureProcessor(variantName, variant); + throw new Exception("A variant has already been assigned to the DataframeAnalysisFeatureProcessorDescriptor. Only a single DataframeAnalysisFeatureProcessor variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void FrequencyEncoding(DataframeAnalysisFeatureProcessorFrequencyEncoding variant) => Set(variant, "frequency_encoding"); + public void FrequencyEncoding(Action> configure) => Set(configure, "frequency_encoding"); + public void MultiEncoding(DataframeAnalysisFeatureProcessorMultiEncoding variant) => Set(variant, "multi_encoding"); + public void MultiEncoding(Action configure) => Set(configure, "multi_encoding"); + public void NGramEncoding(DataframeAnalysisFeatureProcessorNGramEncoding variant) => Set(variant, "n_gram_encoding"); + public void NGramEncoding(Action> configure) => Set(configure, "n_gram_encoding"); + public void OneHotEncoding(DataframeAnalysisFeatureProcessorOneHotEncoding variant) => Set(variant, "one_hot_encoding"); + public void OneHotEncoding(Action> configure) => Set(configure, "one_hot_encoding"); + public void TargetMeanEncoding(DataframeAnalysisFeatureProcessorTargetMeanEncoding variant) => Set(variant, "target_mean_encoding"); + public void TargetMeanEncoding(Action> configure) => Set(configure, "target_mean_encoding"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -183,28 +186,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void FrequencyEncoding(DataframeAnalysisFeatureProcessorFrequencyEncoding variant) => Set(variant, "frequency_encoding"); - public void FrequencyEncoding(Action> configure) => Set(configure, "frequency_encoding"); - public void MultiEncoding(DataframeAnalysisFeatureProcessorMultiEncoding variant) => Set(variant, "multi_encoding"); - public void MultiEncoding(Action configure) => Set(configure, "multi_encoding"); - public void NGramEncoding(DataframeAnalysisFeatureProcessorNGramEncoding variant) => Set(variant, "n_gram_encoding"); - public void NGramEncoding(Action> configure) => Set(configure, "n_gram_encoding"); - public void OneHotEncoding(DataframeAnalysisFeatureProcessorOneHotEncoding variant) => Set(variant, "one_hot_encoding"); - public void OneHotEncoding(Action> configure) => Set(configure, "one_hot_encoding"); - public void TargetMeanEncoding(DataframeAnalysisFeatureProcessorTargetMeanEncoding variant) => Set(variant, "target_mean_encoding"); - public void TargetMeanEncoding(Action> configure) => Set(configure, "target_mean_encoding"); } public sealed partial class DataframeAnalysisFeatureProcessorDescriptor : SerializableDescriptorBase @@ -214,58 +208,35 @@ public DataframeAnalysisFeatureProcessorDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal DataframeAnalysisFeatureProcessor Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the DataframeAnalysisFeatureProcessorDescriptor. Only a single DataframeAnalysisFeatureProcessor variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IDataframeAnalysisFeatureProcessorVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new DataframeAnalysisFeatureProcessor(variantName, variant); + throw new Exception("A variant has already been assigned to the DataframeAnalysisFeatureProcessorDescriptor. Only a single DataframeAnalysisFeatureProcessor variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } - - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } - - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); - } - public void FrequencyEncoding(DataframeAnalysisFeatureProcessorFrequencyEncoding variant) => Set(variant, "frequency_encoding"); public void FrequencyEncoding(Action configure) => Set(configure, "frequency_encoding"); public void FrequencyEncoding(Action> configure) => Set(configure, "frequency_encoding"); @@ -280,5 +251,26 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void TargetMeanEncoding(DataframeAnalysisFeatureProcessorTargetMeanEncoding variant) => Set(variant, "target_mean_encoding"); public void TargetMeanEncoding(Action configure) => Set(configure, "target_mean_encoding"); public void TargetMeanEncoding(Action> configure) => Set(configure, "target_mean_encoding"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorFrequencyEncoding.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorFrequencyEncoding.g.cs index 585bcaa95af..e286aceecb0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorFrequencyEncoding.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorFrequencyEncoding.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class DataframeAnalysisFeatureProcessorFrequencyEncoding : IDataframeAnalysisFeatureProcessorVariant + public sealed partial class DataframeAnalysisFeatureProcessorFrequencyEncoding { [JsonInclude] [JsonPropertyName("feature_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorMultiEncoding.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorMultiEncoding.g.cs index d09155c9ce0..02cb86d3615 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorMultiEncoding.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorMultiEncoding.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class DataframeAnalysisFeatureProcessorMultiEncoding : IDataframeAnalysisFeatureProcessorVariant + public sealed partial class DataframeAnalysisFeatureProcessorMultiEncoding { [JsonInclude] [JsonPropertyName("processors")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorNGramEncoding.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorNGramEncoding.g.cs index f81a8984542..35f5605f875 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorNGramEncoding.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorNGramEncoding.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class DataframeAnalysisFeatureProcessorNGramEncoding : IDataframeAnalysisFeatureProcessorVariant + public sealed partial class DataframeAnalysisFeatureProcessorNGramEncoding { [JsonInclude] [JsonPropertyName("custom")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorOneHotEncoding.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorOneHotEncoding.g.cs index 197b3c857db..e182cccfaa3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorOneHotEncoding.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorOneHotEncoding.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class DataframeAnalysisFeatureProcessorOneHotEncoding : IDataframeAnalysisFeatureProcessorVariant + public sealed partial class DataframeAnalysisFeatureProcessorOneHotEncoding { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorTargetMeanEncoding.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorTargetMeanEncoding.g.cs index 37773ab4e33..7c924f18ec3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorTargetMeanEncoding.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisFeatureProcessorTargetMeanEncoding.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class DataframeAnalysisFeatureProcessorTargetMeanEncoding : IDataframeAnalysisFeatureProcessorVariant + public sealed partial class DataframeAnalysisFeatureProcessorTargetMeanEncoding { [JsonInclude] [JsonPropertyName("default_value")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisOutlierDetection.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisOutlierDetection.g.cs index 7662dd3a33d..6f517ffc338 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisOutlierDetection.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisOutlierDetection.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class DataframeAnalysisOutlierDetection : IDataframeAnalysisVariant + public sealed partial class DataframeAnalysisOutlierDetection { [JsonInclude] [JsonPropertyName("compute_feature_influence")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisRegression.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisRegression.g.cs index 81ba955d731..71d698cd5bf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisRegression.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalysisRegression.g.cs @@ -285,7 +285,7 @@ public override void Write(Utf8JsonWriter writer, DataframeAnalysisRegression va } [JsonConverter(typeof(DataframeAnalysisRegressionConverter))] - public sealed partial class DataframeAnalysisRegression : IDataframeAnalysisVariant + public sealed partial class DataframeAnalysisRegression { public double? Alpha { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalyticsSource.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalyticsSource.g.cs index 4efefa198fc..ff44a219712 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalyticsSource.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeAnalyticsSource.g.cs @@ -40,7 +40,7 @@ public sealed partial class DataframeAnalyticsSource [JsonInclude] [JsonPropertyName("runtime_mappings")] - public Dictionary>? RuntimeMappings { get; set; } + public Dictionary? RuntimeMappings { get; set; } } public sealed partial class DataframeAnalyticsSourceDescriptor : SerializableDescriptorBase> @@ -64,7 +64,7 @@ public DataframeAnalyticsSourceDescriptor() : base() private Elastic.Clients.Elasticsearch.Indices IndexValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } public DataframeAnalyticsSourceDescriptor Query(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? query) { @@ -120,9 +120,9 @@ public DataframeAnalyticsSourceDescriptor Index(Elastic.Clients.Elast return Self; } - public DataframeAnalyticsSourceDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public DataframeAnalyticsSourceDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -194,7 +194,7 @@ public DataframeAnalyticsSourceDescriptor() : base() private Elastic.Clients.Elasticsearch.Indices IndexValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } public DataframeAnalyticsSourceDescriptor Query(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? query) { @@ -250,9 +250,9 @@ public DataframeAnalyticsSourceDescriptor Index(Elastic.Clients.Elasticsearch.In return Self; } - public DataframeAnalyticsSourceDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public DataframeAnalyticsSourceDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationClassification.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationClassification.g.cs index c5a71491f15..671048b80c9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationClassification.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationClassification.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class DataframeEvaluationClassification : IDataframeEvaluationVariant + public sealed partial class DataframeEvaluationClassification { [JsonInclude] [JsonPropertyName("actual_field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationContainer.g.cs index 71c9e95d233..c70805ef301 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public interface IDataframeEvaluationVariant - { - } - [JsonConverter(typeof(DataframeEvaluationContainerConverter))] public sealed partial class DataframeEvaluationContainer { - public DataframeEvaluationContainer(string variantName, IDataframeEvaluationVariant variant) + internal DataframeEvaluationContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public DataframeEvaluationContainer(string variantName, IDataframeEvaluationVari Variant = variant; } - internal IDataframeEvaluationVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -64,7 +60,7 @@ public override DataframeEvaluationContainer Read(ref Utf8JsonReader reader, Typ reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -121,38 +117,41 @@ public DataframeEvaluationContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal DataframeEvaluationContainer Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the DataframeEvaluationContainerDescriptor. Only a single DataframeEvaluationContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IDataframeEvaluationVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new DataframeEvaluationContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the DataframeEvaluationContainerDescriptor. Only a single DataframeEvaluationContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Classification(DataframeEvaluationClassification variant) => Set(variant, "classification"); + public void Classification(Action> configure) => Set(configure, "classification"); + public void OutlierDetection(DataframeEvaluationOutlierDetection variant) => Set(variant, "outlier_detection"); + public void OutlierDetection(Action> configure) => Set(configure, "outlier_detection"); + public void Regression(DataframeEvaluationRegression variant) => Set(variant, "regression"); + public void Regression(Action> configure) => Set(configure, "regression"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -161,24 +160,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Classification(DataframeEvaluationClassification variant) => Set(variant, "classification"); - public void Classification(Action> configure) => Set(configure, "classification"); - public void OutlierDetection(DataframeEvaluationOutlierDetection variant) => Set(variant, "outlier_detection"); - public void OutlierDetection(Action> configure) => Set(configure, "outlier_detection"); - public void Regression(DataframeEvaluationRegression variant) => Set(variant, "regression"); - public void Regression(Action> configure) => Set(configure, "regression"); } public sealed partial class DataframeEvaluationContainerDescriptor : SerializableDescriptorBase @@ -188,38 +182,44 @@ public DataframeEvaluationContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal DataframeEvaluationContainer Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the DataframeEvaluationContainerDescriptor. Only a single DataframeEvaluationContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IDataframeEvaluationVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new DataframeEvaluationContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the DataframeEvaluationContainerDescriptor. Only a single DataframeEvaluationContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Classification(DataframeEvaluationClassification variant) => Set(variant, "classification"); + public void Classification(Action configure) => Set(configure, "classification"); + public void Classification(Action> configure) => Set(configure, "classification"); + public void OutlierDetection(DataframeEvaluationOutlierDetection variant) => Set(variant, "outlier_detection"); + public void OutlierDetection(Action configure) => Set(configure, "outlier_detection"); + public void OutlierDetection(Action> configure) => Set(configure, "outlier_detection"); + public void Regression(DataframeEvaluationRegression variant) => Set(variant, "regression"); + public void Regression(Action configure) => Set(configure, "regression"); + public void Regression(Action> configure) => Set(configure, "regression"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -228,26 +228,18 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Classification(DataframeEvaluationClassification variant) => Set(variant, "classification"); - public void Classification(Action configure) => Set(configure, "classification"); - public void Classification(Action> configure) => Set(configure, "classification"); - public void OutlierDetection(DataframeEvaluationOutlierDetection variant) => Set(variant, "outlier_detection"); - public void OutlierDetection(Action configure) => Set(configure, "outlier_detection"); - public void OutlierDetection(Action> configure) => Set(configure, "outlier_detection"); - public void Regression(DataframeEvaluationRegression variant) => Set(variant, "regression"); - public void Regression(Action configure) => Set(configure, "regression"); - public void Regression(Action> configure) => Set(configure, "regression"); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationOutlierDetection.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationOutlierDetection.g.cs index 7a1717fddb9..46a175b944f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationOutlierDetection.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationOutlierDetection.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class DataframeEvaluationOutlierDetection : IDataframeEvaluationVariant + public sealed partial class DataframeEvaluationOutlierDetection { [JsonInclude] [JsonPropertyName("actual_field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationRegression.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationRegression.g.cs index 684d742a6f9..231b342356f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationRegression.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/DataframeEvaluationRegression.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class DataframeEvaluationRegression : IDataframeEvaluationVariant + public sealed partial class DataframeEvaluationRegression { [JsonInclude] [JsonPropertyName("actual_field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/FillMaskInferenceOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/FillMaskInferenceOptions.g.cs index 814978ef1c0..b461f36dbb2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/FillMaskInferenceOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/FillMaskInferenceOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class FillMaskInferenceOptions : IInferenceConfigCreateVariant + public sealed partial class FillMaskInferenceOptions { [JsonInclude] [JsonPropertyName("num_top_classes")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/FillMaskInferenceUpdateOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/FillMaskInferenceUpdateOptions.g.cs index 7165d7a6393..54f0521270e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/FillMaskInferenceUpdateOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/FillMaskInferenceUpdateOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class FillMaskInferenceUpdateOptions : IInferenceConfigUpdateVariant + public sealed partial class FillMaskInferenceUpdateOptions { [JsonInclude] [JsonPropertyName("num_top_classes")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/FrequencyEncodingPreprocessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/FrequencyEncodingPreprocessor.g.cs index 3fe1611cd85..dd1d0985822 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/FrequencyEncodingPreprocessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/FrequencyEncodingPreprocessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class FrequencyEncodingPreprocessor : IPreprocessorVariant + public sealed partial class FrequencyEncodingPreprocessor { [JsonInclude] [JsonPropertyName("feature_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/InferenceConfigCreateContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/InferenceConfigCreateContainer.g.cs index f892f8edd14..17363bb7641 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/InferenceConfigCreateContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/InferenceConfigCreateContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public interface IInferenceConfigCreateVariant - { - } - [JsonConverter(typeof(InferenceConfigCreateContainerConverter))] public sealed partial class InferenceConfigCreateContainer { - public InferenceConfigCreateContainer(string variantName, IInferenceConfigCreateVariant variant) + internal InferenceConfigCreateContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public InferenceConfigCreateContainer(string variantName, IInferenceConfigCreate Variant = variant; } - internal IInferenceConfigCreateVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -70,7 +66,7 @@ public override InferenceConfigCreateContainer Read(ref Utf8JsonReader reader, T reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -187,58 +183,35 @@ public InferenceConfigCreateContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal InferenceConfigCreateContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the InferenceConfigCreateContainerDescriptor. Only a single InferenceConfigCreateContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IInferenceConfigCreateVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new InferenceConfigCreateContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the InferenceConfigCreateContainerDescriptor. Only a single InferenceConfigCreateContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } - - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } - - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); - } - public void Classification(ClassificationInferenceOptions variant) => Set(variant, "classification"); public void Classification(Action configure) => Set(configure, "classification"); public void FillMask(FillMaskInferenceOptions variant) => Set(variant, "fill_mask"); @@ -257,6 +230,27 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void TextEmbedding(Action configure) => Set(configure, "text_embedding"); public void ZeroShotClassification(ZeroShotClassificationInferenceOptions variant) => Set(variant, "zero_shot_classification"); public void ZeroShotClassification(Action configure) => Set(configure, "zero_shot_classification"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } public sealed partial class InferenceConfigCreateContainerDescriptor : SerializableDescriptorBase @@ -266,58 +260,35 @@ public InferenceConfigCreateContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal InferenceConfigCreateContainer Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the InferenceConfigCreateContainerDescriptor. Only a single InferenceConfigCreateContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IInferenceConfigCreateVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new InferenceConfigCreateContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the InferenceConfigCreateContainerDescriptor. Only a single InferenceConfigCreateContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } - - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } - - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); - } - public void Classification(ClassificationInferenceOptions variant) => Set(variant, "classification"); public void Classification(Action configure) => Set(configure, "classification"); public void FillMask(FillMaskInferenceOptions variant) => Set(variant, "fill_mask"); @@ -337,5 +308,26 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void TextEmbedding(Action configure) => Set(configure, "text_embedding"); public void ZeroShotClassification(ZeroShotClassificationInferenceOptions variant) => Set(variant, "zero_shot_classification"); public void ZeroShotClassification(Action configure) => Set(configure, "zero_shot_classification"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/InferenceConfigUpdateContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/InferenceConfigUpdateContainer.g.cs index 0076de89496..b080ca02091 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/InferenceConfigUpdateContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/InferenceConfigUpdateContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public interface IInferenceConfigUpdateVariant - { - } - [JsonConverter(typeof(InferenceConfigUpdateContainerConverter))] public sealed partial class InferenceConfigUpdateContainer { - public InferenceConfigUpdateContainer(string variantName, IInferenceConfigUpdateVariant variant) + internal InferenceConfigUpdateContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public InferenceConfigUpdateContainer(string variantName, IInferenceConfigUpdate Variant = variant; } - internal IInferenceConfigUpdateVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -70,7 +66,7 @@ public override InferenceConfigUpdateContainer Read(ref Utf8JsonReader reader, T reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -187,58 +183,35 @@ public InferenceConfigUpdateContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal InferenceConfigUpdateContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the InferenceConfigUpdateContainerDescriptor. Only a single InferenceConfigUpdateContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IInferenceConfigUpdateVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new InferenceConfigUpdateContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the InferenceConfigUpdateContainerDescriptor. Only a single InferenceConfigUpdateContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } - - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } - - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); - } - public void Classification(ClassificationInferenceOptions variant) => Set(variant, "classification"); public void Classification(Action configure) => Set(configure, "classification"); public void FillMask(FillMaskInferenceUpdateOptions variant) => Set(variant, "fill_mask"); @@ -257,6 +230,27 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void TextEmbedding(Action configure) => Set(configure, "text_embedding"); public void ZeroShotClassification(ZeroShotClassificationInferenceUpdateOptions variant) => Set(variant, "zero_shot_classification"); public void ZeroShotClassification(Action configure) => Set(configure, "zero_shot_classification"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } public sealed partial class InferenceConfigUpdateContainerDescriptor : SerializableDescriptorBase @@ -266,58 +260,35 @@ public InferenceConfigUpdateContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal InferenceConfigUpdateContainer Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the InferenceConfigUpdateContainerDescriptor. Only a single InferenceConfigUpdateContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IInferenceConfigUpdateVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new InferenceConfigUpdateContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the InferenceConfigUpdateContainerDescriptor. Only a single InferenceConfigUpdateContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } - - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } - - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); - } - public void Classification(ClassificationInferenceOptions variant) => Set(variant, "classification"); public void Classification(Action configure) => Set(configure, "classification"); public void FillMask(FillMaskInferenceUpdateOptions variant) => Set(variant, "fill_mask"); @@ -337,5 +308,26 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void TextEmbedding(Action configure) => Set(configure, "text_embedding"); public void ZeroShotClassification(ZeroShotClassificationInferenceUpdateOptions variant) => Set(variant, "zero_shot_classification"); public void ZeroShotClassification(Action configure) => Set(configure, "zero_shot_classification"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NerInferenceOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NerInferenceOptions.g.cs index 79659c97eab..4edc05adc89 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NerInferenceOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NerInferenceOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class NerInferenceOptions : IInferenceConfigCreateVariant + public sealed partial class NerInferenceOptions { [JsonInclude] [JsonPropertyName("classification_labels")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NerInferenceUpdateOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NerInferenceUpdateOptions.g.cs index 1dbe1b84a41..04e097e0653 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NerInferenceUpdateOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NerInferenceUpdateOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class NerInferenceUpdateOptions : IInferenceConfigUpdateVariant + public sealed partial class NerInferenceUpdateOptions { [JsonInclude] [JsonPropertyName("results_field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NlpBertTokenizationConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NlpBertTokenizationConfig.g.cs index 8ccfa856006..0c2f67805a0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NlpBertTokenizationConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NlpBertTokenizationConfig.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class NlpBertTokenizationConfig : ITokenizationConfigVariant + public sealed partial class NlpBertTokenizationConfig { [JsonInclude] [JsonPropertyName("do_lower_case")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NlpRobertaTokenizationConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NlpRobertaTokenizationConfig.g.cs index 40c4c9d549f..18749fd0f04 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NlpRobertaTokenizationConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NlpRobertaTokenizationConfig.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class NlpRobertaTokenizationConfig : ITokenizationConfigVariant + public sealed partial class NlpRobertaTokenizationConfig { [JsonInclude] [JsonPropertyName("add_prefix_space")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/OneHotEncodingPreprocessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/OneHotEncodingPreprocessor.g.cs index 64e4edf35db..8afde6bb6b5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/OneHotEncodingPreprocessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/OneHotEncodingPreprocessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class OneHotEncodingPreprocessor : IPreprocessorVariant + public sealed partial class OneHotEncodingPreprocessor { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/PassThroughInferenceOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/PassThroughInferenceOptions.g.cs index 18eff73b550..f64377fb2d7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/PassThroughInferenceOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/PassThroughInferenceOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class PassThroughInferenceOptions : IInferenceConfigCreateVariant + public sealed partial class PassThroughInferenceOptions { [JsonInclude] [JsonPropertyName("results_field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/PassThroughInferenceUpdateOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/PassThroughInferenceUpdateOptions.g.cs index dae487fff2f..739d27aa1c1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/PassThroughInferenceUpdateOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/PassThroughInferenceUpdateOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class PassThroughInferenceUpdateOptions : IInferenceConfigUpdateVariant + public sealed partial class PassThroughInferenceUpdateOptions { [JsonInclude] [JsonPropertyName("results_field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/Preprocessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/Preprocessor.g.cs index e30bd2c5304..f2b5f54b1a3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/Preprocessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/Preprocessor.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public interface IPreprocessorVariant - { - } - [JsonConverter(typeof(PreprocessorConverter))] public sealed partial class Preprocessor { - public Preprocessor(string variantName, IPreprocessorVariant variant) + internal Preprocessor(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public Preprocessor(string variantName, IPreprocessorVariant variant) Variant = variant; } - internal IPreprocessorVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -64,7 +60,7 @@ public override Preprocessor Read(ref Utf8JsonReader reader, Type typeToConvert, reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -121,38 +117,41 @@ public PreprocessorDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal Preprocessor Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the PreprocessorDescriptor. Only a single Preprocessor variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IPreprocessorVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new Preprocessor(variantName, variant); + throw new Exception("A variant has already been assigned to the PreprocessorDescriptor. Only a single Preprocessor variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void FrequencyEncoding(FrequencyEncodingPreprocessor variant) => Set(variant, "frequency_encoding"); + public void FrequencyEncoding(Action> configure) => Set(configure, "frequency_encoding"); + public void OneHotEncoding(OneHotEncodingPreprocessor variant) => Set(variant, "one_hot_encoding"); + public void OneHotEncoding(Action> configure) => Set(configure, "one_hot_encoding"); + public void TargetMeanEncoding(TargetMeanEncodingPreprocessor variant) => Set(variant, "target_mean_encoding"); + public void TargetMeanEncoding(Action> configure) => Set(configure, "target_mean_encoding"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -161,24 +160,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void FrequencyEncoding(FrequencyEncodingPreprocessor variant) => Set(variant, "frequency_encoding"); - public void FrequencyEncoding(Action> configure) => Set(configure, "frequency_encoding"); - public void OneHotEncoding(OneHotEncodingPreprocessor variant) => Set(variant, "one_hot_encoding"); - public void OneHotEncoding(Action> configure) => Set(configure, "one_hot_encoding"); - public void TargetMeanEncoding(TargetMeanEncodingPreprocessor variant) => Set(variant, "target_mean_encoding"); - public void TargetMeanEncoding(Action> configure) => Set(configure, "target_mean_encoding"); } public sealed partial class PreprocessorDescriptor : SerializableDescriptorBase @@ -188,38 +182,44 @@ public PreprocessorDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal Preprocessor Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the PreprocessorDescriptor. Only a single Preprocessor variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IPreprocessorVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new Preprocessor(variantName, variant); + throw new Exception("A variant has already been assigned to the PreprocessorDescriptor. Only a single Preprocessor variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void FrequencyEncoding(FrequencyEncodingPreprocessor variant) => Set(variant, "frequency_encoding"); + public void FrequencyEncoding(Action configure) => Set(configure, "frequency_encoding"); + public void FrequencyEncoding(Action> configure) => Set(configure, "frequency_encoding"); + public void OneHotEncoding(OneHotEncodingPreprocessor variant) => Set(variant, "one_hot_encoding"); + public void OneHotEncoding(Action configure) => Set(configure, "one_hot_encoding"); + public void OneHotEncoding(Action> configure) => Set(configure, "one_hot_encoding"); + public void TargetMeanEncoding(TargetMeanEncodingPreprocessor variant) => Set(variant, "target_mean_encoding"); + public void TargetMeanEncoding(Action configure) => Set(configure, "target_mean_encoding"); + public void TargetMeanEncoding(Action> configure) => Set(configure, "target_mean_encoding"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -228,26 +228,18 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void FrequencyEncoding(FrequencyEncodingPreprocessor variant) => Set(variant, "frequency_encoding"); - public void FrequencyEncoding(Action configure) => Set(configure, "frequency_encoding"); - public void FrequencyEncoding(Action> configure) => Set(configure, "frequency_encoding"); - public void OneHotEncoding(OneHotEncodingPreprocessor variant) => Set(variant, "one_hot_encoding"); - public void OneHotEncoding(Action configure) => Set(configure, "one_hot_encoding"); - public void OneHotEncoding(Action> configure) => Set(configure, "one_hot_encoding"); - public void TargetMeanEncoding(TargetMeanEncodingPreprocessor variant) => Set(variant, "target_mean_encoding"); - public void TargetMeanEncoding(Action configure) => Set(configure, "target_mean_encoding"); - public void TargetMeanEncoding(Action> configure) => Set(configure, "target_mean_encoding"); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/QuestionAnsweringInferenceOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/QuestionAnsweringInferenceOptions.g.cs index 1b155dae18a..eb361930fe6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/QuestionAnsweringInferenceOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/QuestionAnsweringInferenceOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class QuestionAnsweringInferenceOptions : IInferenceConfigCreateVariant + public sealed partial class QuestionAnsweringInferenceOptions { [JsonInclude] [JsonPropertyName("max_answer_length")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/QuestionAnsweringInferenceUpdateOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/QuestionAnsweringInferenceUpdateOptions.g.cs index 5a18253603a..46057a9c61f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/QuestionAnsweringInferenceUpdateOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/QuestionAnsweringInferenceUpdateOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class QuestionAnsweringInferenceUpdateOptions : IInferenceConfigUpdateVariant + public sealed partial class QuestionAnsweringInferenceUpdateOptions { [JsonInclude] [JsonPropertyName("max_answer_length")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/RegressionInferenceOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/RegressionInferenceOptions.g.cs index 26a1e6f4b81..0c1c9689fd4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/RegressionInferenceOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/RegressionInferenceOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class RegressionInferenceOptions : Aggregations.IInferenceConfigVariant, IInferenceConfigCreateVariant, IInferenceConfigUpdateVariant + public sealed partial class RegressionInferenceOptions { [JsonInclude] [JsonPropertyName("num_top_feature_importance_values")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TargetMeanEncodingPreprocessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TargetMeanEncodingPreprocessor.g.cs index 220e1d01542..971b4d1fdd5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TargetMeanEncodingPreprocessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TargetMeanEncodingPreprocessor.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class TargetMeanEncodingPreprocessor : IPreprocessorVariant + public sealed partial class TargetMeanEncodingPreprocessor { [JsonInclude] [JsonPropertyName("default_value")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextClassificationInferenceOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextClassificationInferenceOptions.g.cs index e96b35ab569..9a576c1eb4c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextClassificationInferenceOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextClassificationInferenceOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class TextClassificationInferenceOptions : IInferenceConfigCreateVariant + public sealed partial class TextClassificationInferenceOptions { [JsonInclude] [JsonPropertyName("classification_labels")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextClassificationInferenceUpdateOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextClassificationInferenceUpdateOptions.g.cs index 27718727d85..998b004ecdf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextClassificationInferenceUpdateOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextClassificationInferenceUpdateOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class TextClassificationInferenceUpdateOptions : IInferenceConfigUpdateVariant + public sealed partial class TextClassificationInferenceUpdateOptions { [JsonInclude] [JsonPropertyName("classification_labels")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextEmbeddingInferenceOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextEmbeddingInferenceOptions.g.cs index 9b3bec3551b..ea05ff9efb5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextEmbeddingInferenceOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextEmbeddingInferenceOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class TextEmbeddingInferenceOptions : IInferenceConfigCreateVariant + public sealed partial class TextEmbeddingInferenceOptions { [JsonInclude] [JsonPropertyName("results_field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextEmbeddingInferenceUpdateOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextEmbeddingInferenceUpdateOptions.g.cs index 18795d49e1f..9905c592018 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextEmbeddingInferenceUpdateOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TextEmbeddingInferenceUpdateOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class TextEmbeddingInferenceUpdateOptions : IInferenceConfigUpdateVariant + public sealed partial class TextEmbeddingInferenceUpdateOptions { [JsonInclude] [JsonPropertyName("results_field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TokenizationConfigContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TokenizationConfigContainer.g.cs index c15cf181e1f..40cceed800d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TokenizationConfigContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TokenizationConfigContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public interface ITokenizationConfigVariant - { - } - [JsonConverter(typeof(TokenizationConfigContainerConverter))] public sealed partial class TokenizationConfigContainer { - public TokenizationConfigContainer(string variantName, ITokenizationConfigVariant variant) + internal TokenizationConfigContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public TokenizationConfigContainer(string variantName, ITokenizationConfigVarian Variant = variant; } - internal ITokenizationConfigVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -64,7 +60,7 @@ public override TokenizationConfigContainer Read(ref Utf8JsonReader reader, Type reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -121,38 +117,41 @@ public TokenizationConfigContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal TokenizationConfigContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the TokenizationConfigContainerDescriptor. Only a single TokenizationConfigContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(ITokenizationConfigVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new TokenizationConfigContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the TokenizationConfigContainerDescriptor. Only a single TokenizationConfigContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Bert(NlpBertTokenizationConfig variant) => Set(variant, "bert"); + public void Bert(Action configure) => Set(configure, "bert"); + public void Mpnet(NlpBertTokenizationConfig variant) => Set(variant, "mpnet"); + public void Mpnet(Action configure) => Set(configure, "mpnet"); + public void Roberta(NlpRobertaTokenizationConfig variant) => Set(variant, "roberta"); + public void Roberta(Action configure) => Set(configure, "roberta"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -161,24 +160,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Bert(NlpBertTokenizationConfig variant) => Set(variant, "bert"); - public void Bert(Action configure) => Set(configure, "bert"); - public void Mpnet(NlpBertTokenizationConfig variant) => Set(variant, "mpnet"); - public void Mpnet(Action configure) => Set(configure, "mpnet"); - public void Roberta(NlpRobertaTokenizationConfig variant) => Set(variant, "roberta"); - public void Roberta(Action configure) => Set(configure, "roberta"); } public sealed partial class TokenizationConfigContainerDescriptor : SerializableDescriptorBase @@ -188,38 +182,41 @@ public TokenizationConfigContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal TokenizationConfigContainer Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the TokenizationConfigContainerDescriptor. Only a single TokenizationConfigContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(ITokenizationConfigVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new TokenizationConfigContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the TokenizationConfigContainerDescriptor. Only a single TokenizationConfigContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Bert(NlpBertTokenizationConfig variant) => Set(variant, "bert"); + public void Bert(Action configure) => Set(configure, "bert"); + public void Mpnet(NlpBertTokenizationConfig variant) => Set(variant, "mpnet"); + public void Mpnet(Action configure) => Set(configure, "mpnet"); + public void Roberta(NlpRobertaTokenizationConfig variant) => Set(variant, "roberta"); + public void Roberta(Action configure) => Set(configure, "roberta"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -228,23 +225,18 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Bert(NlpBertTokenizationConfig variant) => Set(variant, "bert"); - public void Bert(Action configure) => Set(configure, "bert"); - public void Mpnet(NlpBertTokenizationConfig variant) => Set(variant, "mpnet"); - public void Mpnet(Action configure) => Set(configure, "mpnet"); - public void Roberta(NlpRobertaTokenizationConfig variant) => Set(variant, "roberta"); - public void Roberta(Action configure) => Set(configure, "roberta"); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TrainedModelAllocationRoutingTable.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TrainedModelAssignmentRoutingTable.g.cs similarity index 85% rename from src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TrainedModelAllocationRoutingTable.g.cs rename to src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TrainedModelAssignmentRoutingTable.g.cs index 032d128ca03..e761b70289e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TrainedModelAllocationRoutingTable.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TrainedModelAssignmentRoutingTable.g.cs @@ -24,8 +24,12 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class TrainedModelAllocationRoutingTable + public sealed partial class TrainedModelAssignmentRoutingTable { + [JsonInclude] + [JsonPropertyName("current_allocations")] + public int CurrentAllocations { get; init; } + [JsonInclude] [JsonPropertyName("reason")] public string Reason { get; init; } @@ -33,5 +37,9 @@ public sealed partial class TrainedModelAllocationRoutingTable [JsonInclude] [JsonPropertyName("routing_state")] public Elastic.Clients.Elasticsearch.Ml.RoutingState RoutingState { get; init; } + + [JsonInclude] + [JsonPropertyName("target_allocations")] + public int TargetAllocations { get; init; } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TrainedModelDeploymentNodesStats.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TrainedModelDeploymentNodesStats.g.cs index 8e0e23ffecb..09eaa9337be 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TrainedModelDeploymentNodesStats.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/TrainedModelDeploymentNodesStats.g.cs @@ -60,7 +60,7 @@ public sealed partial class TrainedModelDeploymentNodesStats [JsonInclude] [JsonPropertyName("routing_state")] - public Elastic.Clients.Elasticsearch.Ml.TrainedModelAllocationRoutingTable RoutingState { get; init; } + public Elastic.Clients.Elasticsearch.Ml.TrainedModelAssignmentRoutingTable RoutingState { get; init; } [JsonInclude] [JsonPropertyName("start_time")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/ZeroShotClassificationInferenceOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/ZeroShotClassificationInferenceOptions.g.cs index a8ebeb7ad54..e17eb5f95f5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/ZeroShotClassificationInferenceOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/ZeroShotClassificationInferenceOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class ZeroShotClassificationInferenceOptions : IInferenceConfigCreateVariant + public sealed partial class ZeroShotClassificationInferenceOptions { [JsonInclude] [JsonPropertyName("classification_labels")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/ZeroShotClassificationInferenceUpdateOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/ZeroShotClassificationInferenceUpdateOptions.g.cs index 51a7488a387..934632cfe6f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/ZeroShotClassificationInferenceUpdateOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/ZeroShotClassificationInferenceUpdateOptions.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.Ml { - public sealed partial class ZeroShotClassificationInferenceUpdateOptions : IInferenceConfigUpdateVariant + public sealed partial class ZeroShotClassificationInferenceUpdateOptions { [JsonInclude] [JsonPropertyName("labels")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MultisearchBody.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MultisearchBody.g.cs index d2208eea5fe..3042dd41841 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MultisearchBody.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MultisearchBody.g.cs @@ -66,6 +66,12 @@ public override MultisearchBody Read(ref Utf8JsonReader reader, Type typeToConve continue; } + if (property == "ext") + { + variant.Ext = JsonSerializer.Deserialize?>(ref reader, options); + continue; + } + if (property == "fields") { variant.Fields = JsonSerializer.Deserialize?>(ref reader, options); @@ -128,7 +134,7 @@ public override MultisearchBody Read(ref Utf8JsonReader reader, Type typeToConve if (property == "runtime_mappings") { - variant.RuntimeMappings = JsonSerializer.Deserialize>?>(ref reader, options); + variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); continue; } @@ -248,6 +254,12 @@ public override void Write(Utf8JsonWriter writer, MultisearchBody value, JsonSer writer.WriteBooleanValue(value.Explain.Value); } + if (value.Ext is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, value.Ext, options); + } + if (value.Fields is not null) { writer.WritePropertyName("fields"); @@ -409,6 +421,8 @@ public sealed partial class MultisearchBody public bool? Explain { get; set; } + public Dictionary? Ext { get; set; } + public IEnumerable? Fields { get; set; } public int? From { get; set; } @@ -429,7 +443,7 @@ public sealed partial class MultisearchBody public IEnumerable? Rescore { get; set; } - public Dictionary>? RuntimeMappings { get; set; } + public Dictionary? RuntimeMappings { get; set; } public Dictionary? ScriptFields { get; set; } @@ -520,6 +534,8 @@ public MultisearchBodyDescriptor() : base() private bool? ExplainValue { get; set; } + private Dictionary? ExtValue { get; set; } + private int? FromValue { get; set; } private IEnumerable>? IndicesBoostValue { get; set; } @@ -534,7 +550,7 @@ public MultisearchBodyDescriptor() : base() private bool? ProfileValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private Dictionary? ScriptFieldsValue { get; set; } @@ -788,6 +804,12 @@ public MultisearchBodyDescriptor Explain(bool? explain = true) return Self; } + public MultisearchBodyDescriptor Ext(Func, FluentDictionary> selector) + { + ExtValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + public MultisearchBodyDescriptor From(int? from) { FromValue = from; @@ -836,9 +858,9 @@ public MultisearchBodyDescriptor Profile(bool? profile = true) return Self; } - public MultisearchBodyDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public MultisearchBodyDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -1122,6 +1144,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteBooleanValue(ExplainValue.Value); } + if (ExtValue is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, ExtValue, options); + } + if (FromValue.HasValue) { writer.WritePropertyName("from"); @@ -1321,6 +1349,8 @@ public MultisearchBodyDescriptor() : base() private bool? ExplainValue { get; set; } + private Dictionary? ExtValue { get; set; } + private int? FromValue { get; set; } private IEnumerable>? IndicesBoostValue { get; set; } @@ -1335,7 +1365,7 @@ public MultisearchBodyDescriptor() : base() private bool? ProfileValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private Dictionary? ScriptFieldsValue { get; set; } @@ -1589,6 +1619,12 @@ public MultisearchBodyDescriptor Explain(bool? explain = true) return Self; } + public MultisearchBodyDescriptor Ext(Func, FluentDictionary> selector) + { + ExtValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + public MultisearchBodyDescriptor From(int? from) { FromValue = from; @@ -1637,9 +1673,9 @@ public MultisearchBodyDescriptor Profile(bool? profile = true) return Self; } - public MultisearchBodyDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public MultisearchBodyDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -1929,6 +1965,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteBooleanValue(ExplainValue.Value); } + if (ExtValue is not null) + { + writer.WritePropertyName("ext"); + JsonSerializer.Serialize(writer, ExtValue, options); + } + if (FromValue.HasValue) { writer.WritePropertyName("from"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/PhraseSuggester.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/PhraseSuggester.g.cs index dfb6b3e8717..cc8a05747da 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/PhraseSuggester.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/PhraseSuggester.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public sealed partial class PhraseSuggester : IFieldSuggesterVariant + public sealed partial class PhraseSuggester { [JsonInclude] [JsonPropertyName("analyzer")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoolQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoolQuery.g.cs index 53324bff528..b417df3fbe1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoolQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoolQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class BoolQuery : Query, IQueryVariant + public sealed partial class BoolQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoostingQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoostingQuery.g.cs index 04610494cf4..24c347e4cd4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoostingQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoostingQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class BoostingQuery : Query, IQueryVariant + public sealed partial class BoostingQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs index 745621e6471..61b96be2073 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class CombinedFieldsQuery : Query, IQueryVariant + public sealed partial class CombinedFieldsQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ConstantScoreQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ConstantScoreQuery.g.cs index be2cea204c8..775919841be 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ConstantScoreQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ConstantScoreQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class ConstantScoreQuery : Query, IQueryVariant + public sealed partial class ConstantScoreQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateRangeQuery.g.cs index e66bc0a5189..1a716a8bb05 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateRangeQuery.g.cs @@ -31,12 +31,9 @@ public override DateRangeQuery Read(ref Utf8JsonReader reader, Type typeToConver if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new DateRangeQuery() - { Field = fieldName }; + var variant = new DateRangeQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -110,7 +107,6 @@ public override DateRangeQuery Read(ref Utf8JsonReader reader, Type typeToConver } } - reader.Read(); reader.Read(); return variant; } @@ -118,7 +114,7 @@ public override DateRangeQuery Read(ref Utf8JsonReader reader, Type typeToConver public override void Write(Utf8JsonWriter writer, DateRangeQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize DateRangeQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -195,13 +191,20 @@ public override void Write(Utf8JsonWriter writer, DateRangeQuery value, JsonSeri return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(DateRangeQueryConverter))] - public sealed partial class DateRangeQuery : Query, IQueryVariant + public sealed partial class DateRangeQuery : Query { + public DateRangeQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public float? Boost { get; set; } @@ -224,21 +227,35 @@ public sealed partial class DateRangeQuery : Query, IQueryVariant public Elastic.Clients.Elasticsearch.DateMath? To { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class DateRangeQueryDescriptor : SerializableDescriptorBase> { internal DateRangeQueryDescriptor(Action> configure) => configure.Invoke(this); - public DateRangeQueryDescriptor() : base() + internal DateRangeQueryDescriptor() : base() + { + } + + public DateRangeQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public DateRangeQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string? FormatValue { get; set; } @@ -270,7 +287,7 @@ public DateRangeQueryDescriptor Boost(float? boost) return Self; } - public DateRangeQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public DateRangeQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -338,6 +355,8 @@ public DateRangeQueryDescriptor To(Elastic.Clients.Elasticsearch.Date 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(); @@ -415,15 +434,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class DateRangeQueryDescriptor : SerializableDescriptorBase { internal DateRangeQueryDescriptor(Action configure) => configure.Invoke(this); - public DateRangeQueryDescriptor() : base() + internal DateRangeQueryDescriptor() : base() { } + public DateRangeQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string? FormatValue { get; set; } @@ -455,7 +481,7 @@ public DateRangeQueryDescriptor Boost(float? boost) return Self; } - public DateRangeQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public DateRangeQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -529,6 +555,8 @@ public DateRangeQueryDescriptor To(Elastic.Clients.Elasticsearch.DateMath? to) 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(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DisMaxQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DisMaxQuery.g.cs index 018ee6432df..08d4bd339d1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DisMaxQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DisMaxQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class DisMaxQuery : Query, IQueryVariant + public sealed partial class DisMaxQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ExistsQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ExistsQuery.g.cs index e5a9b87b3d2..8641843b3b7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ExistsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ExistsQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class ExistsQuery : Query, IQueryVariant + public sealed partial class ExistsQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldValueFactorScoreFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldValueFactorScoreFunction.g.cs index 5d32b5ebb94..c4293c327ee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldValueFactorScoreFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldValueFactorScoreFunction.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class FieldValueFactorScoreFunction : IFunctionScoreVariant + public sealed partial class FieldValueFactorScoreFunction { [JsonInclude] [JsonPropertyName("factor")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreContainer.g.cs index f61e014aa8e..b2157fb13d1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public interface IFunctionScoreVariant - { - } - [JsonConverter(typeof(FunctionScoreContainerConverter))] public sealed partial class FunctionScoreContainer { - public FunctionScoreContainer(string variantName, IFunctionScoreVariant variant) + internal FunctionScoreContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public FunctionScoreContainer(string variantName, IFunctionScoreVariant variant) Variant = variant; } - internal IFunctionScoreVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -68,41 +64,82 @@ public override FunctionScoreContainer Read(ref Utf8JsonReader reader, Type type throw new JsonException("Expected start token."); } - reader.Read(); - if (reader.TokenType != JsonTokenType.PropertyName) + object? variantValue = default; + string? variantNameValue = default; + Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? filterValue = default; + double? weightValue = default; + while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { - throw new JsonException("Expected property name token."); - } + if (reader.TokenType != JsonTokenType.PropertyName) + { + throw new JsonException("Expected a property name token."); + } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "field_value_factor") - { - var variant = JsonSerializer.Deserialize(ref reader, options); - reader.Read(); - return new FunctionScoreContainer(propertyName, variant); - } + if (reader.TokenType != JsonTokenType.PropertyName) + { + throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); + } - if (propertyName == "random_score") - { - var variant = JsonSerializer.Deserialize(ref reader, options); + var propertyName = reader.GetString(); reader.Read(); - return new FunctionScoreContainer(propertyName, variant); + if (propertyName == "filter") + { + filterValue = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (propertyName == "weight") + { + weightValue = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (propertyName == "field_value_factor") + { + variantValue = JsonSerializer.Deserialize(ref reader, options); + variantNameValue = propertyName; + continue; + } + + if (propertyName == "random_score") + { + variantValue = JsonSerializer.Deserialize(ref reader, options); + variantNameValue = propertyName; + continue; + } + + if (propertyName == "script_score") + { + variantValue = JsonSerializer.Deserialize(ref reader, options); + variantNameValue = propertyName; + continue; + } + + throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'FunctionScoreContainer' from the response."); } - if (propertyName == "script_score") - { - var variant = JsonSerializer.Deserialize(ref reader, options); - reader.Read(); - return new FunctionScoreContainer(propertyName, variant); - } - - throw new JsonException(); + reader.Read(); + var result = new FunctionScoreContainer(variantNameValue, variantValue); + result.Filter = filterValue; + result.Weight = weightValue; + return result; } public override void Write(Utf8JsonWriter writer, FunctionScoreContainer value, JsonSerializerOptions options) { writer.WriteStartObject(); + if (value.Filter is not null) + { + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, value.Filter, options); + } + + if (value.Weight.HasValue) + { + writer.WritePropertyName("weight"); + writer.WriteNumberValue(value.Weight.Value); + } + writer.WritePropertyName(value.VariantName); switch (value.VariantName) { @@ -128,38 +165,79 @@ public FunctionScoreContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal FunctionScoreContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the FunctionScoreContainerDescriptor. Only a single FunctionScoreContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IFunctionScoreVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new FunctionScoreContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the FunctionScoreContainerDescriptor. Only a single FunctionScoreContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + private Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? FilterValue { get; set; } + + private QueryContainerDescriptor FilterDescriptor { get; set; } + + private Action> FilterDescriptorAction { get; set; } + + private double? WeightValue { get; set; } + + public FunctionScoreContainerDescriptor Filter(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? filter) + { + FilterDescriptor = null; + FilterDescriptorAction = null; + FilterValue = filter; + return Self; + } + + public FunctionScoreContainerDescriptor Filter(QueryContainerDescriptor descriptor) + { + FilterValue = null; + FilterDescriptorAction = null; + FilterDescriptor = descriptor; + return Self; + } + + public FunctionScoreContainerDescriptor Filter(Action> configure) + { + FilterValue = null; + FilterDescriptor = null; + FilterDescriptorAction = configure; + return Self; + } + + public FunctionScoreContainerDescriptor Weight(double? weight) + { + WeightValue = weight; + return Self; + } + + public void FieldValueFactor(FieldValueFactorScoreFunction variant) => Set(variant, "field_value_factor"); + public void FieldValueFactor(Action> configure) => Set(configure, "field_value_factor"); + public void RandomScore(RandomScoreFunction variant) => Set(variant, "random_score"); + public void RandomScore(Action> configure) => Set(configure, "random_score"); + public void ScriptScore(ScriptScoreFunction variant) => Set(variant, "script_score"); + public void ScriptScore(Action configure) => Set(configure, "script_score"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -168,24 +246,41 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + if (FilterDescriptor is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, FilterDescriptor, options); + } + else if (FilterDescriptorAction is not null) + { + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, new QueryContainerDescriptor(FilterDescriptorAction), options); + } + else if (FilterValue is not null) + { + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, FilterValue, options); + } + + if (WeightValue.HasValue) + { + writer.WritePropertyName("weight"); + writer.WriteNumberValue(WeightValue.Value); } - writer.WriteStartObject(); writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + writer.WriteEndObject(); } - - public void FieldValueFactor(FieldValueFactorScoreFunction variant) => Set(variant, "field_value_factor"); - public void FieldValueFactor(Action> configure) => Set(configure, "field_value_factor"); - public void RandomScore(RandomScoreFunction variant) => Set(variant, "random_score"); - public void RandomScore(Action> configure) => Set(configure, "random_score"); - public void ScriptScore(ScriptScoreFunction variant) => Set(variant, "script_score"); - public void ScriptScore(Action configure) => Set(configure, "script_score"); } public sealed partial class FunctionScoreContainerDescriptor : SerializableDescriptorBase @@ -195,38 +290,81 @@ public FunctionScoreContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal FunctionScoreContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the FunctionScoreContainerDescriptor. Only a single FunctionScoreContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IFunctionScoreVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new FunctionScoreContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the FunctionScoreContainerDescriptor. Only a single FunctionScoreContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + private Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? FilterValue { get; set; } + + private QueryContainerDescriptor FilterDescriptor { get; set; } + + private Action FilterDescriptorAction { get; set; } + + private double? WeightValue { get; set; } + + public FunctionScoreContainerDescriptor Filter(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? filter) + { + FilterDescriptor = null; + FilterDescriptorAction = null; + FilterValue = filter; + return Self; + } + + public FunctionScoreContainerDescriptor Filter(QueryContainerDescriptor descriptor) + { + FilterValue = null; + FilterDescriptorAction = null; + FilterDescriptor = descriptor; + return Self; + } + + public FunctionScoreContainerDescriptor Filter(Action configure) + { + FilterValue = null; + FilterDescriptor = null; + FilterDescriptorAction = configure; + return Self; + } + + public FunctionScoreContainerDescriptor Weight(double? weight) + { + WeightValue = weight; + return Self; + } + + public void FieldValueFactor(FieldValueFactorScoreFunction variant) => Set(variant, "field_value_factor"); + public void FieldValueFactor(Action configure) => Set(configure, "field_value_factor"); + public void FieldValueFactor(Action> configure) => Set(configure, "field_value_factor"); + public void RandomScore(RandomScoreFunction variant) => Set(variant, "random_score"); + public void RandomScore(Action configure) => Set(configure, "random_score"); + public void RandomScore(Action> configure) => Set(configure, "random_score"); + public void ScriptScore(ScriptScoreFunction variant) => Set(variant, "script_score"); + public void ScriptScore(Action configure) => Set(configure, "script_score"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -235,25 +373,40 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + if (FilterDescriptor is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, FilterDescriptor, options); + } + else if (FilterDescriptorAction is not null) + { + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, new QueryContainerDescriptor(FilterDescriptorAction), options); + } + else if (FilterValue is not null) + { + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, FilterValue, options); + } + + if (WeightValue.HasValue) + { + writer.WritePropertyName("weight"); + writer.WriteNumberValue(WeightValue.Value); } - writer.WriteStartObject(); writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + writer.WriteEndObject(); } - - public void FieldValueFactor(FieldValueFactorScoreFunction variant) => Set(variant, "field_value_factor"); - public void FieldValueFactor(Action configure) => Set(configure, "field_value_factor"); - public void FieldValueFactor(Action> configure) => Set(configure, "field_value_factor"); - public void RandomScore(RandomScoreFunction variant) => Set(variant, "random_score"); - public void RandomScore(Action configure) => Set(configure, "random_score"); - public void RandomScore(Action> configure) => Set(configure, "random_score"); - public void ScriptScore(ScriptScoreFunction variant) => Set(variant, "script_score"); - public void ScriptScore(Action configure) => Set(configure, "script_score"); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs index 13530e640a9..a430191432d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class FunctionScoreQuery : Query, IQueryVariant + public sealed partial class FunctionScoreQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FuzzyQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FuzzyQuery.g.cs index 64149bdfd55..11e21836949 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FuzzyQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FuzzyQuery.g.cs @@ -31,12 +31,9 @@ public override FuzzyQuery Read(ref Utf8JsonReader reader, Type typeToConvert, J if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new FuzzyQuery() - { Field = fieldName }; + var variant = new FuzzyQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -92,7 +89,6 @@ public override FuzzyQuery Read(ref Utf8JsonReader reader, Type typeToConvert, J } } - reader.Read(); reader.Read(); return variant; } @@ -100,7 +96,7 @@ public override FuzzyQuery Read(ref Utf8JsonReader reader, Type typeToConvert, J public override void Write(Utf8JsonWriter writer, FuzzyQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize FuzzyQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -155,13 +151,20 @@ public override void Write(Utf8JsonWriter writer, FuzzyQuery value, JsonSerializ return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(FuzzyQueryConverter))] - public sealed partial class FuzzyQuery : Query, IQueryVariant + public sealed partial class FuzzyQuery : Query { + public FuzzyQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public float? Boost { get; set; } @@ -178,21 +181,35 @@ public sealed partial class FuzzyQuery : Query, IQueryVariant public object Value { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class FuzzyQueryDescriptor : SerializableDescriptorBase> { internal FuzzyQueryDescriptor(Action> configure) => configure.Invoke(this); - public FuzzyQueryDescriptor() : base() + internal FuzzyQueryDescriptor() : base() + { + } + + public FuzzyQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public FuzzyQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private Elastic.Clients.Elasticsearch.Fuzziness? FuzzinessValue { get; set; } @@ -218,7 +235,7 @@ public FuzzyQueryDescriptor Boost(float? boost) return Self; } - public FuzzyQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public FuzzyQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -268,6 +285,8 @@ public FuzzyQueryDescriptor Value(object value) 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(); @@ -323,15 +342,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class FuzzyQueryDescriptor : SerializableDescriptorBase { internal FuzzyQueryDescriptor(Action configure) => configure.Invoke(this); - public FuzzyQueryDescriptor() : base() + internal FuzzyQueryDescriptor() : base() { } + public FuzzyQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private Elastic.Clients.Elasticsearch.Fuzziness? FuzzinessValue { get; set; } @@ -357,7 +383,7 @@ public FuzzyQueryDescriptor Boost(float? boost) return Self; } - public FuzzyQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public FuzzyQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -413,6 +439,8 @@ public FuzzyQueryDescriptor Value(object value) 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(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs index 9bb007ac5c2..5f55c187a4c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs @@ -113,7 +113,7 @@ public override void Write(Utf8JsonWriter writer, GeoBoundingBoxQuery value, Jso } [JsonConverter(typeof(GeoBoundingBoxQueryConverter))] - public sealed partial class GeoBoundingBoxQuery : Query, IQueryVariant + public sealed partial class GeoBoundingBoxQuery : Query { public string? QueryName { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs index 958a01c0451..fa3b2bd10c9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs @@ -125,7 +125,7 @@ public override void Write(Utf8JsonWriter writer, GeoDistanceQuery value, JsonSe } [JsonConverter(typeof(GeoDistanceQueryConverter))] - public sealed partial class GeoDistanceQuery : Query, IQueryVariant + public sealed partial class GeoDistanceQuery : Query { public string? QueryName { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoPolygonQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoPolygonQuery.g.cs index 23c2f657a05..8816086e7d4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoPolygonQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoPolygonQuery.g.cs @@ -113,7 +113,7 @@ public override void Write(Utf8JsonWriter writer, GeoPolygonQuery value, JsonSer } [JsonConverter(typeof(GeoPolygonQueryConverter))] - public sealed partial class GeoPolygonQuery : Query, IQueryVariant + public sealed partial class GeoPolygonQuery : Query { public string? QueryName { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs index dc41b5cdf1a..1329b8a7b3b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs @@ -101,7 +101,7 @@ public override void Write(Utf8JsonWriter writer, GeoShapeQuery value, JsonSeria } [JsonConverter(typeof(GeoShapeQueryConverter))] - public sealed partial class GeoShapeQuery : Query, IQueryVariant + public sealed partial class GeoShapeQuery : Query { public string? QueryName { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/HasChildQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/HasChildQuery.g.cs index 943dae5c66f..a6d1154ef42 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/HasChildQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/HasChildQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class HasChildQuery : Query, IQueryVariant + public sealed partial class HasChildQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/HasParentQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/HasParentQuery.g.cs index 2648f407743..d58ef570fdf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/HasParentQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/HasParentQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class HasParentQuery : Query, IQueryVariant + public sealed partial class HasParentQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IdsQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IdsQuery.g.cs index 341aea87b75..c62c585d0b6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IdsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IdsQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class IdsQuery : Query, IQueryVariant + public sealed partial class IdsQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsAllOf.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsAllOf.g.cs index 6eb17ae30e1..5f7e377fd4b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsAllOf.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsAllOf.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class IntervalsAllOf : IIntervalsVariant, IIntervalsQueryVariant + public sealed partial class IntervalsAllOf { [JsonInclude] [JsonPropertyName("filter")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsAnyOf.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsAnyOf.g.cs index f7bdb754abf..0f7105b7812 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsAnyOf.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsAnyOf.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class IntervalsAnyOf : IIntervalsVariant, IIntervalsQueryVariant + public sealed partial class IntervalsAnyOf { [JsonInclude] [JsonPropertyName("filter")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsContainer.g.cs index 051deb517ca..20ceb447c8a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public interface IIntervalsVariant - { - } - [JsonConverter(typeof(IntervalsContainerConverter))] public sealed partial class IntervalsContainer { - public IntervalsContainer(string variantName, IIntervalsVariant variant) + internal IntervalsContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public IntervalsContainer(string variantName, IIntervalsVariant variant) Variant = variant; } - internal IIntervalsVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -67,7 +63,7 @@ public override IntervalsContainer Read(ref Utf8JsonReader reader, Type typeToCo reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -154,38 +150,47 @@ public IntervalsContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal IntervalsContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the IntervalsContainerDescriptor. Only a single IntervalsContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IIntervalsVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new IntervalsContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the IntervalsContainerDescriptor. Only a single IntervalsContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void AllOf(IntervalsAllOf variant) => Set(variant, "all_of"); + public void AllOf(Action> configure) => Set(configure, "all_of"); + public void AnyOf(IntervalsAnyOf variant) => Set(variant, "any_of"); + public void AnyOf(Action> configure) => Set(configure, "any_of"); + public void Fuzzy(IntervalsFuzzy variant) => Set(variant, "fuzzy"); + public void Fuzzy(Action> configure) => Set(configure, "fuzzy"); + public void Match(IntervalsMatch variant) => Set(variant, "match"); + public void Match(Action> configure) => Set(configure, "match"); + public void Prefix(IntervalsPrefix variant) => Set(variant, "prefix"); + public void Prefix(Action> configure) => Set(configure, "prefix"); + public void Wildcard(IntervalsWildcard variant) => Set(variant, "wildcard"); + public void Wildcard(Action> configure) => Set(configure, "wildcard"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -194,30 +199,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void AllOf(IntervalsAllOf variant) => Set(variant, "all_of"); - public void AllOf(Action> configure) => Set(configure, "all_of"); - public void AnyOf(IntervalsAnyOf variant) => Set(variant, "any_of"); - public void AnyOf(Action> configure) => Set(configure, "any_of"); - public void Fuzzy(IntervalsFuzzy variant) => Set(variant, "fuzzy"); - public void Fuzzy(Action> configure) => Set(configure, "fuzzy"); - public void Match(IntervalsMatch variant) => Set(variant, "match"); - public void Match(Action> configure) => Set(configure, "match"); - public void Prefix(IntervalsPrefix variant) => Set(variant, "prefix"); - public void Prefix(Action> configure) => Set(configure, "prefix"); - public void Wildcard(IntervalsWildcard variant) => Set(variant, "wildcard"); - public void Wildcard(Action> configure) => Set(configure, "wildcard"); } public sealed partial class IntervalsContainerDescriptor : SerializableDescriptorBase @@ -227,58 +221,35 @@ public IntervalsContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal IntervalsContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the IntervalsContainerDescriptor. Only a single IntervalsContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IIntervalsVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new IntervalsContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the IntervalsContainerDescriptor. Only a single IntervalsContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } - - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } - - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); - } - public void AllOf(IntervalsAllOf variant) => Set(variant, "all_of"); public void AllOf(Action configure) => Set(configure, "all_of"); public void AllOf(Action> configure) => Set(configure, "all_of"); @@ -297,5 +268,26 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void Wildcard(IntervalsWildcard variant) => Set(variant, "wildcard"); public void Wildcard(Action configure) => Set(configure, "wildcard"); public void Wildcard(Action> configure) => Set(configure, "wildcard"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFilter.g.cs index 1ff1c3c709c..af763476e76 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFilter.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public interface IIntervalsFilterVariant - { - } - [JsonConverter(typeof(IntervalsFilterConverter))] public sealed partial class IntervalsFilter { - public IntervalsFilter(string variantName, IIntervalsFilterVariant variant) + internal IntervalsFilter(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public IntervalsFilter(string variantName, IIntervalsFilterVariant variant) Variant = variant; } - internal IIntervalsFilterVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } } @@ -60,7 +56,7 @@ public override IntervalsFilter Read(ref Utf8JsonReader reader, Type typeToConve reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -83,34 +79,31 @@ public IntervalsFilterDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal IntervalsFilter Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the IntervalsFilterDescriptor. Only a single IntervalsFilter variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IIntervalsFilterVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new IntervalsFilter(variantName, variant); + throw new Exception("A variant has already been assigned to the IntervalsFilterDescriptor. Only a single IntervalsFilter variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } @@ -123,15 +116,17 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } } @@ -143,34 +138,31 @@ public IntervalsFilterDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal IntervalsFilter Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the IntervalsFilterDescriptor. Only a single IntervalsFilter variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IIntervalsFilterVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new IntervalsFilter(variantName, variant); + throw new Exception("A variant has already been assigned to the IntervalsFilterDescriptor. Only a single IntervalsFilter variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } @@ -183,15 +175,17 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFuzzy.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFuzzy.g.cs index 11c6fce5469..6be584a1d41 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFuzzy.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFuzzy.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class IntervalsFuzzy : IIntervalsVariant, IIntervalsQueryVariant + public sealed partial class IntervalsFuzzy { [JsonInclude] [JsonPropertyName("analyzer")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsMatch.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsMatch.g.cs index ac559f3b848..ed698143287 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsMatch.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsMatch.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class IntervalsMatch : IIntervalsVariant, IIntervalsQueryVariant + public sealed partial class IntervalsMatch { [JsonInclude] [JsonPropertyName("analyzer")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsPrefix.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsPrefix.g.cs index 58e11d4bc11..76b765d6a41 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsPrefix.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsPrefix.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class IntervalsPrefix : IIntervalsVariant, IIntervalsQueryVariant + public sealed partial class IntervalsPrefix { [JsonInclude] [JsonPropertyName("analyzer")] 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 c4a5331ac74..39eed164078 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs @@ -24,14 +24,12 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public interface IIntervalsQueryVariant - { - } - [JsonConverter(typeof(IntervalsQueryConverter))] - public sealed partial class IntervalsQuery : Query, IQueryVariant + public sealed partial class IntervalsQuery : Query { - public IntervalsQuery(string variantName, IIntervalsQueryVariant variant) + internal object Variant { get; } + + internal IntervalsQuery(Field field, string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -39,20 +37,21 @@ public IntervalsQuery(string variantName, IIntervalsQueryVariant variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); + if (field is null) + throw new ArgumentNullException(nameof(field)); VariantName = variantName; Variant = variant; + Field = field; } - internal IIntervalsQueryVariant Variant { get; } - internal string VariantName { get; } - public static IntervalsQuery AllOf(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf intervalsAllOf) => new IntervalsQuery("all_of", intervalsAllOf); - public static IntervalsQuery AnyOf(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf intervalsAnyOf) => new IntervalsQuery("any_of", intervalsAnyOf); - public static IntervalsQuery Fuzzy(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsFuzzy intervalsFuzzy) => new IntervalsQuery("fuzzy", intervalsFuzzy); - public static IntervalsQuery Match(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsMatch intervalsMatch) => new IntervalsQuery("match", intervalsMatch); - public static IntervalsQuery Prefix(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsPrefix intervalsPrefix) => new IntervalsQuery("prefix", intervalsPrefix); - public static IntervalsQuery Wildcard(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsWildcard intervalsWildcard) => new IntervalsQuery("wildcard", intervalsWildcard); + public static IntervalsQuery AllOf(Field field, Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf intervalsAllOf) => new IntervalsQuery(field, "all_of", intervalsAllOf); + public static IntervalsQuery AnyOf(Field field, Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf intervalsAnyOf) => new IntervalsQuery(field, "any_of", intervalsAnyOf); + public static IntervalsQuery Fuzzy(Field field, Elastic.Clients.Elasticsearch.QueryDsl.IntervalsFuzzy intervalsFuzzy) => new IntervalsQuery(field, "fuzzy", intervalsFuzzy); + public static IntervalsQuery Match(Field field, Elastic.Clients.Elasticsearch.QueryDsl.IntervalsMatch intervalsMatch) => new IntervalsQuery(field, "match", intervalsMatch); + public static IntervalsQuery Prefix(Field field, Elastic.Clients.Elasticsearch.QueryDsl.IntervalsPrefix intervalsPrefix) => new IntervalsQuery(field, "prefix", intervalsPrefix); + public static IntervalsQuery Wildcard(Field field, Elastic.Clients.Elasticsearch.QueryDsl.IntervalsWildcard intervalsWildcard) => new IntervalsQuery(field, "wildcard", intervalsWildcard); [JsonInclude] [JsonPropertyName("_name")] public string? QueryName { get; set; } @@ -63,7 +62,7 @@ public IntervalsQuery(string variantName, IIntervalsQueryVariant variant) [JsonInclude] [JsonPropertyName("field")] - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } internal sealed class IntervalsQueryConverter : JsonConverter @@ -78,143 +77,217 @@ public override IntervalsQuery Read(ref Utf8JsonReader reader, Type typeToConver reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); } - var propertyName = reader.GetString(); + var fieldName = reader.GetString(); reader.Read(); - if (propertyName == "all_of") + object? variantValue = default; + string? variantNameValue = default; + string? nameValue = default; + float? boostValue = default; + while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { - var variant = JsonSerializer.Deserialize(ref reader, options); - reader.Read(); - return new IntervalsQuery(propertyName, variant); - } + if (reader.TokenType != JsonTokenType.PropertyName) + { + throw new JsonException("Expected a property name token."); + } - if (propertyName == "any_of") - { - var variant = JsonSerializer.Deserialize(ref reader, options); - reader.Read(); - return new IntervalsQuery(propertyName, variant); - } - - if (propertyName == "fuzzy") - { - var variant = JsonSerializer.Deserialize(ref reader, options); - reader.Read(); - return new IntervalsQuery(propertyName, variant); - } + if (reader.TokenType != JsonTokenType.PropertyName) + { + throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); + } - if (propertyName == "match") - { - var variant = JsonSerializer.Deserialize(ref reader, options); + var propertyName = reader.GetString(); reader.Read(); - return new IntervalsQuery(propertyName, variant); + if (propertyName == "_name") + { + nameValue = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (propertyName == "boost") + { + boostValue = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (propertyName == "all_of") + { + variantValue = JsonSerializer.Deserialize(ref reader, options); + variantNameValue = propertyName; + continue; + } + + if (propertyName == "any_of") + { + variantValue = JsonSerializer.Deserialize(ref reader, options); + variantNameValue = propertyName; + continue; + } + + if (propertyName == "fuzzy") + { + variantValue = JsonSerializer.Deserialize(ref reader, options); + variantNameValue = propertyName; + continue; + } + + if (propertyName == "match") + { + variantValue = JsonSerializer.Deserialize(ref reader, options); + variantNameValue = propertyName; + continue; + } + + if (propertyName == "prefix") + { + variantValue = JsonSerializer.Deserialize(ref reader, options); + variantNameValue = propertyName; + continue; + } + + if (propertyName == "wildcard") + { + variantValue = JsonSerializer.Deserialize(ref reader, options); + variantNameValue = propertyName; + continue; + } + + throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IntervalsQuery' from the response."); } - if (propertyName == "prefix") - { - var variant = JsonSerializer.Deserialize(ref reader, options); - reader.Read(); - return new IntervalsQuery(propertyName, variant); - } - - if (propertyName == "wildcard") - { - var variant = JsonSerializer.Deserialize(ref reader, options); - reader.Read(); - return new IntervalsQuery(propertyName, variant); - } - - throw new JsonException(); + reader.Read(); + var result = new IntervalsQuery(fieldName, variantNameValue, variantValue); + result.QueryName = nameValue; + result.Boost = boostValue; + return result; } public override void Write(Utf8JsonWriter writer, IntervalsQuery value, JsonSerializerOptions options) { - writer.WriteStartObject(); - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) + 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)) { - case "all_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf)value.Variant, options); - break; - case "any_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf)value.Variant, options); - break; - case "fuzzy": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsFuzzy)value.Variant, options); - break; - case "match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsMatch)value.Variant, options); - break; - case "prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsPrefix)value.Variant, options); - break; - case "wildcard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsWildcard)value.Variant, options); - break; + writer.WriteStartObject(); + writer.WritePropertyName(settings.Inferrer.Field(value.Field)); + writer.WriteStartObject(); + if (!string.IsNullOrEmpty(value.QueryName)) + { + writer.WritePropertyName("_name"); + writer.WriteStringValue(value.QueryName); + } + + if (value.Boost.HasValue) + { + writer.WritePropertyName("boost"); + writer.WriteNumberValue(value.Boost.Value); + } + + writer.WritePropertyName(value.VariantName); + switch (value.VariantName) + { + case "all_of": + JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf)value.Variant, options); + break; + case "any_of": + JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf)value.Variant, options); + break; + case "fuzzy": + JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsFuzzy)value.Variant, options); + break; + case "match": + JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsMatch)value.Variant, options); + break; + case "prefix": + JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsPrefix)value.Variant, options); + break; + case "wildcard": + JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsWildcard)value.Variant, options); + break; + } + + writer.WriteEndObject(); + writer.WriteEndObject(); + return; } - writer.WriteEndObject(); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } public sealed partial class IntervalsQueryDescriptor : SerializableDescriptorBase> { internal IntervalsQueryDescriptor(Action> configure) => configure.Invoke(this); - public IntervalsQueryDescriptor() : base() + internal IntervalsQueryDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + public IntervalsQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal IntervalsQuery Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the IntervalsQueryDescriptor. Only a single IntervalsQuery variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IIntervalsQueryVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new IntervalsQuery(variantName, variant); + throw new Exception("A variant has already been assigned to the IntervalsQueryDescriptor. Only a single IntervalsQuery variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + private string? QueryNameValue { get; set; } + + private float? BoostValue { get; set; } + + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } + + public IntervalsQueryDescriptor QueryName(string? queryName) { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } + QueryNameValue = queryName; + return Self; + } - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } + public IntervalsQueryDescriptor Boost(float? boost) + { + BoostValue = boost; + return Self; + } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); + public IntervalsQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) + { + FieldValue = field; + return Self; + } + + public IntervalsQueryDescriptor Field(Expression> field) + { + FieldValue = field; + return Self; } public void AllOf(IntervalsAllOf variant) => Set(variant, "all_of"); @@ -229,65 +302,121 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void Prefix(Action> configure) => Set(configure, "prefix"); public void Wildcard(IntervalsWildcard variant) => Set(variant, "wildcard"); public void Wildcard(Action> configure) => Set(configure, "wildcard"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(settings.Inferrer.Field(FieldValue)); + writer.WriteStartObject(); + if (!string.IsNullOrEmpty(QueryNameValue)) + { + writer.WritePropertyName("_name"); + writer.WriteStringValue(QueryNameValue); + } + + if (BoostValue.HasValue) + { + writer.WritePropertyName("boost"); + writer.WriteNumberValue(BoostValue.Value); + } + + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + writer.WriteEndObject(); + } } public sealed partial class IntervalsQueryDescriptor : SerializableDescriptorBase { internal IntervalsQueryDescriptor(Action configure) => configure.Invoke(this); - public IntervalsQueryDescriptor() : base() + internal IntervalsQueryDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + public IntervalsQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal IntervalsQuery Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the IntervalsQueryDescriptor. Only a single IntervalsQuery variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IIntervalsQueryVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new IntervalsQuery(variantName, variant); + throw new Exception("A variant has already been assigned to the IntervalsQueryDescriptor. Only a single IntervalsQuery variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + private string? QueryNameValue { get; set; } + + private float? BoostValue { get; set; } + + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } + + public IntervalsQueryDescriptor QueryName(string? queryName) { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } + QueryNameValue = queryName; + return Self; + } - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } + public IntervalsQueryDescriptor Boost(float? boost) + { + BoostValue = boost; + return Self; + } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); + 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 void AllOf(IntervalsAllOf variant) => Set(variant, "all_of"); @@ -308,5 +437,41 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void Wildcard(IntervalsWildcard variant) => Set(variant, "wildcard"); public void Wildcard(Action configure) => Set(configure, "wildcard"); public void Wildcard(Action> configure) => Set(configure, "wildcard"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(settings.Inferrer.Field(FieldValue)); + writer.WriteStartObject(); + if (!string.IsNullOrEmpty(QueryNameValue)) + { + writer.WritePropertyName("_name"); + writer.WriteStringValue(QueryNameValue); + } + + if (BoostValue.HasValue) + { + writer.WritePropertyName("boost"); + writer.WriteNumberValue(BoostValue.Value); + } + + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + writer.WriteEndObject(); + } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsWildcard.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsWildcard.g.cs index 741455fcd20..e85e5f086b4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsWildcard.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsWildcard.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class IntervalsWildcard : IIntervalsVariant, IIntervalsQueryVariant + public sealed partial class IntervalsWildcard { [JsonInclude] [JsonPropertyName("analyzer")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/KnnQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/KnnQuery.g.cs deleted file mode 100644 index 691d24c9039..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/KnnQuery.g.cs +++ /dev/null @@ -1,211 +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 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 KnnQuery : Query, IQueryVariant - { - [JsonInclude] - [JsonPropertyName("_name")] - public string? QueryName { get; set; } - - [JsonInclude] - [JsonPropertyName("boost")] - public float? Boost { get; set; } - - [JsonInclude] - [JsonPropertyName("field")] - public Elastic.Clients.Elasticsearch.Field Field { get; set; } - - [JsonInclude] - [JsonPropertyName("num_candidates")] - public int NumCandidates { get; set; } - - [JsonInclude] - [JsonPropertyName("query_vector")] - public IEnumerable QueryVector { get; set; } - } - - public sealed partial class KnnQueryDescriptor : SerializableDescriptorBase> - { - internal KnnQueryDescriptor(Action> configure) => configure.Invoke(this); - public KnnQueryDescriptor() : base() - { - } - - private string? QueryNameValue { get; set; } - - private float? BoostValue { get; set; } - - private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } - - private int NumCandidatesValue { get; set; } - - private IEnumerable QueryVectorValue { get; set; } - - public KnnQueryDescriptor QueryName(string? queryName) - { - QueryNameValue = queryName; - return Self; - } - - public KnnQueryDescriptor Boost(float? boost) - { - BoostValue = boost; - return Self; - } - - public KnnQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) - { - FieldValue = field; - return Self; - } - - public KnnQueryDescriptor Field(Expression> field) - { - FieldValue = field; - return Self; - } - - public KnnQueryDescriptor NumCandidates(int numCandidates) - { - NumCandidatesValue = numCandidates; - return Self; - } - - public KnnQueryDescriptor QueryVector(IEnumerable queryVector) - { - QueryVectorValue = queryVector; - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - writer.WriteStartObject(); - if (!string.IsNullOrEmpty(QueryNameValue)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(QueryNameValue); - } - - if (BoostValue.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(BoostValue.Value); - } - - writer.WritePropertyName("field"); - JsonSerializer.Serialize(writer, FieldValue, options); - writer.WritePropertyName("num_candidates"); - writer.WriteNumberValue(NumCandidatesValue); - writer.WritePropertyName("query_vector"); - JsonSerializer.Serialize(writer, QueryVectorValue, options); - writer.WriteEndObject(); - } - } - - public sealed partial class KnnQueryDescriptor : SerializableDescriptorBase - { - internal KnnQueryDescriptor(Action configure) => configure.Invoke(this); - public KnnQueryDescriptor() : base() - { - } - - private string? QueryNameValue { get; set; } - - private float? BoostValue { get; set; } - - private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } - - private int NumCandidatesValue { get; set; } - - private IEnumerable QueryVectorValue { get; set; } - - public KnnQueryDescriptor QueryName(string? queryName) - { - QueryNameValue = queryName; - return Self; - } - - public KnnQueryDescriptor Boost(float? boost) - { - BoostValue = boost; - return Self; - } - - public KnnQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) - { - FieldValue = field; - return Self; - } - - public KnnQueryDescriptor Field(Expression> field) - { - FieldValue = field; - return Self; - } - - public KnnQueryDescriptor Field(Expression> field) - { - FieldValue = field; - return Self; - } - - public KnnQueryDescriptor NumCandidates(int numCandidates) - { - NumCandidatesValue = numCandidates; - return Self; - } - - public KnnQueryDescriptor QueryVector(IEnumerable queryVector) - { - QueryVectorValue = queryVector; - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - writer.WriteStartObject(); - if (!string.IsNullOrEmpty(QueryNameValue)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(QueryNameValue); - } - - if (BoostValue.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(BoostValue.Value); - } - - writer.WritePropertyName("field"); - JsonSerializer.Serialize(writer, FieldValue, options); - writer.WritePropertyName("num_candidates"); - writer.WriteNumberValue(NumCandidatesValue); - writer.WritePropertyName("query_vector"); - JsonSerializer.Serialize(writer, QueryVectorValue, options); - writer.WriteEndObject(); - } - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchAllQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchAllQuery.g.cs index 2d3bd26d36c..d712eef8125 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchAllQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchAllQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class MatchAllQuery : Query, IQueryVariant + public sealed partial class MatchAllQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs index d42edfe8497..937b9ecaf89 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs @@ -31,12 +31,9 @@ public override MatchBoolPrefixQuery Read(ref Utf8JsonReader reader, Type typeTo if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new MatchBoolPrefixQuery() - { Field = fieldName }; + var variant = new MatchBoolPrefixQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -110,7 +107,6 @@ public override MatchBoolPrefixQuery Read(ref Utf8JsonReader reader, Type typeTo } } - reader.Read(); reader.Read(); return variant; } @@ -118,7 +114,7 @@ public override MatchBoolPrefixQuery Read(ref Utf8JsonReader reader, Type typeTo public override void Write(Utf8JsonWriter writer, MatchBoolPrefixQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize MatchBoolPrefixQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -191,13 +187,20 @@ public override void Write(Utf8JsonWriter writer, MatchBoolPrefixQuery value, Js return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(MatchBoolPrefixQueryConverter))] - public sealed partial class MatchBoolPrefixQuery : Query, IQueryVariant + public sealed partial class MatchBoolPrefixQuery : Query { + public MatchBoolPrefixQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public string? Analyzer { get; set; } @@ -220,14 +223,28 @@ public sealed partial class MatchBoolPrefixQuery : Query, IQueryVariant public string Query { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class MatchBoolPrefixQueryDescriptor : SerializableDescriptorBase> { internal MatchBoolPrefixQueryDescriptor(Action> configure) => configure.Invoke(this); - public MatchBoolPrefixQueryDescriptor() : base() + internal MatchBoolPrefixQueryDescriptor() : base() + { + } + + public MatchBoolPrefixQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public MatchBoolPrefixQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } @@ -236,7 +253,7 @@ public MatchBoolPrefixQueryDescriptor() : base() private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private Elastic.Clients.Elasticsearch.Fuzziness? FuzzinessValue { get; set; } @@ -272,7 +289,7 @@ public MatchBoolPrefixQueryDescriptor Boost(float? boost) return Self; } - public MatchBoolPrefixQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public MatchBoolPrefixQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -334,6 +351,8 @@ public MatchBoolPrefixQueryDescriptor Query(string query) 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(); @@ -407,17 +426,24 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class MatchBoolPrefixQueryDescriptor : SerializableDescriptorBase { internal MatchBoolPrefixQueryDescriptor(Action configure) => configure.Invoke(this); - public MatchBoolPrefixQueryDescriptor() : base() + internal MatchBoolPrefixQueryDescriptor() : base() { } + public MatchBoolPrefixQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private string? AnalyzerValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private Elastic.Clients.Elasticsearch.Fuzziness? FuzzinessValue { get; set; } @@ -453,7 +479,7 @@ public MatchBoolPrefixQueryDescriptor Boost(float? boost) return Self; } - public MatchBoolPrefixQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public MatchBoolPrefixQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -521,6 +547,8 @@ public MatchBoolPrefixQueryDescriptor Query(string query) 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(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchNoneQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchNoneQuery.g.cs index f9ca6bd6e67..0256f7d44bf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchNoneQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchNoneQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class MatchNoneQuery : Query, IQueryVariant + public sealed partial class MatchNoneQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs index 4f0a6fe960e..0cca1f90a81 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs @@ -31,12 +31,9 @@ public override MatchPhrasePrefixQuery Read(ref Utf8JsonReader reader, Type type if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new MatchPhrasePrefixQuery() - { Field = fieldName }; + var variant = new MatchPhrasePrefixQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -86,7 +83,6 @@ public override MatchPhrasePrefixQuery Read(ref Utf8JsonReader reader, Type type } } - reader.Read(); reader.Read(); return variant; } @@ -94,7 +90,7 @@ public override MatchPhrasePrefixQuery Read(ref Utf8JsonReader reader, Type type public override void Write(Utf8JsonWriter writer, MatchPhrasePrefixQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize MatchPhrasePrefixQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -143,13 +139,20 @@ public override void Write(Utf8JsonWriter writer, MatchPhrasePrefixQuery value, return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(MatchPhrasePrefixQueryConverter))] - public sealed partial class MatchPhrasePrefixQuery : Query, IQueryVariant + public sealed partial class MatchPhrasePrefixQuery : Query { + public MatchPhrasePrefixQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public string? Analyzer { get; set; } @@ -164,14 +167,28 @@ public sealed partial class MatchPhrasePrefixQuery : Query, IQueryVariant public Elastic.Clients.Elasticsearch.QueryDsl.ZeroTermsQuery? ZeroTermsQuery { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class MatchPhrasePrefixQueryDescriptor : SerializableDescriptorBase> { internal MatchPhrasePrefixQueryDescriptor(Action> configure) => configure.Invoke(this); - public MatchPhrasePrefixQueryDescriptor() : base() + internal MatchPhrasePrefixQueryDescriptor() : base() + { + } + + public MatchPhrasePrefixQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public MatchPhrasePrefixQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } @@ -180,7 +197,7 @@ public MatchPhrasePrefixQueryDescriptor() : base() private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private int? MaxExpansionsValue { get; set; } @@ -208,7 +225,7 @@ public MatchPhrasePrefixQueryDescriptor Boost(float? boost) return Self; } - public MatchPhrasePrefixQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public MatchPhrasePrefixQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -246,6 +263,8 @@ public MatchPhrasePrefixQueryDescriptor ZeroTermsQuery(Elastic.Client 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(); @@ -295,17 +314,24 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class MatchPhrasePrefixQueryDescriptor : SerializableDescriptorBase { internal MatchPhrasePrefixQueryDescriptor(Action configure) => configure.Invoke(this); - public MatchPhrasePrefixQueryDescriptor() : base() + internal MatchPhrasePrefixQueryDescriptor() : base() { } + public MatchPhrasePrefixQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private string? AnalyzerValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private int? MaxExpansionsValue { get; set; } @@ -333,7 +359,7 @@ public MatchPhrasePrefixQueryDescriptor Boost(float? boost) return Self; } - public MatchPhrasePrefixQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public MatchPhrasePrefixQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -377,6 +403,8 @@ public MatchPhrasePrefixQueryDescriptor ZeroTermsQuery(Elastic.Clients.Elasticse 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(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs index 2263fa3c4cd..e5b3459454d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs @@ -31,12 +31,9 @@ public override MatchPhraseQuery Read(ref Utf8JsonReader reader, Type typeToConv if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new MatchPhraseQuery() - { Field = fieldName }; + var variant = new MatchPhraseQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -80,7 +77,6 @@ public override MatchPhraseQuery Read(ref Utf8JsonReader reader, Type typeToConv } } - reader.Read(); reader.Read(); return variant; } @@ -88,7 +84,7 @@ public override MatchPhraseQuery Read(ref Utf8JsonReader reader, Type typeToConv public override void Write(Utf8JsonWriter writer, MatchPhraseQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize MatchPhraseQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -131,13 +127,20 @@ public override void Write(Utf8JsonWriter writer, MatchPhraseQuery value, JsonSe return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(MatchPhraseQueryConverter))] - public sealed partial class MatchPhraseQuery : Query, IQueryVariant + public sealed partial class MatchPhraseQuery : Query { + public MatchPhraseQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public string? Analyzer { get; set; } @@ -150,14 +153,28 @@ public sealed partial class MatchPhraseQuery : Query, IQueryVariant public Elastic.Clients.Elasticsearch.QueryDsl.ZeroTermsQuery? ZeroTermsQuery { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class MatchPhraseQueryDescriptor : SerializableDescriptorBase> { internal MatchPhraseQueryDescriptor(Action> configure) => configure.Invoke(this); - public MatchPhraseQueryDescriptor() : base() + internal MatchPhraseQueryDescriptor() : base() + { + } + + public MatchPhraseQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public MatchPhraseQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } @@ -166,7 +183,7 @@ public MatchPhraseQueryDescriptor() : base() private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string QueryValue { get; set; } @@ -192,7 +209,7 @@ public MatchPhraseQueryDescriptor Boost(float? boost) return Self; } - public MatchPhraseQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public MatchPhraseQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -224,6 +241,8 @@ public MatchPhraseQueryDescriptor ZeroTermsQuery(Elastic.Clients.Elas 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(); @@ -267,17 +286,24 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class MatchPhraseQueryDescriptor : SerializableDescriptorBase { internal MatchPhraseQueryDescriptor(Action configure) => configure.Invoke(this); - public MatchPhraseQueryDescriptor() : base() + internal MatchPhraseQueryDescriptor() : base() { } + public MatchPhraseQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private string? AnalyzerValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string QueryValue { get; set; } @@ -303,7 +329,7 @@ public MatchPhraseQueryDescriptor Boost(float? boost) return Self; } - public MatchPhraseQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public MatchPhraseQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -341,6 +367,8 @@ public MatchPhraseQueryDescriptor ZeroTermsQuery(Elastic.Clients.Elasticsearch.Q 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(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchQuery.g.cs index 8b062bcae3a..b0c7da916ae 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchQuery.g.cs @@ -31,12 +31,9 @@ public override MatchQuery Read(ref Utf8JsonReader reader, Type typeToConvert, J if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new MatchQuery() - { Field = fieldName }; + var variant = new MatchQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -128,7 +125,6 @@ public override MatchQuery Read(ref Utf8JsonReader reader, Type typeToConvert, J } } - reader.Read(); reader.Read(); return variant; } @@ -136,7 +132,7 @@ public override MatchQuery Read(ref Utf8JsonReader reader, Type typeToConvert, J public override void Write(Utf8JsonWriter writer, MatchQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize MatchQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -227,13 +223,20 @@ public override void Write(Utf8JsonWriter writer, MatchQuery value, JsonSerializ return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(MatchQueryConverter))] - public sealed partial class MatchQuery : Query, IQueryVariant + public sealed partial class MatchQuery : Query { + public MatchQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public string? Analyzer { get; set; } @@ -262,14 +265,28 @@ public sealed partial class MatchQuery : Query, IQueryVariant public Elastic.Clients.Elasticsearch.QueryDsl.ZeroTermsQuery? ZeroTermsQuery { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class MatchQueryDescriptor : SerializableDescriptorBase> { internal MatchQueryDescriptor(Action> configure) => configure.Invoke(this); - public MatchQueryDescriptor() : base() + internal MatchQueryDescriptor() : base() + { + } + + public MatchQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public MatchQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } @@ -280,7 +297,7 @@ public MatchQueryDescriptor() : base() private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private Elastic.Clients.Elasticsearch.Fuzziness? FuzzinessValue { get; set; } @@ -326,7 +343,7 @@ public MatchQueryDescriptor Boost(float? boost) return Self; } - public MatchQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public MatchQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -400,6 +417,8 @@ public MatchQueryDescriptor ZeroTermsQuery(Elastic.Clients.Elasticsea 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(); @@ -491,10 +510,17 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class MatchQueryDescriptor : SerializableDescriptorBase { internal MatchQueryDescriptor(Action configure) => configure.Invoke(this); - public MatchQueryDescriptor() : base() + internal MatchQueryDescriptor() : base() { } + public MatchQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private string? AnalyzerValue { get; set; } @@ -503,7 +529,7 @@ public MatchQueryDescriptor() : base() private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private Elastic.Clients.Elasticsearch.Fuzziness? FuzzinessValue { get; set; } @@ -549,7 +575,7 @@ public MatchQueryDescriptor Boost(float? boost) return Self; } - public MatchQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public MatchQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -629,6 +655,8 @@ public MatchQueryDescriptor ZeroTermsQuery(Elastic.Clients.Elasticsearch.QueryDs 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(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs index 0d2a941433b..a651e52aa12 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class MoreLikeThisQuery : Query, IQueryVariant + public sealed partial class MoreLikeThisQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs index d74a2dec176..1e7ded45119 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class MultiMatchQuery : Query, IQueryVariant + public sealed partial class MultiMatchQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NestedQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NestedQuery.g.cs index 26099034c52..aefca35932e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NestedQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NestedQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class NestedQuery : Query, IQueryVariant + public sealed partial class NestedQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs index bc5ad8289fd..f2d04b2375f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs @@ -31,12 +31,9 @@ public override NumberRangeQuery Read(ref Utf8JsonReader reader, Type typeToConv if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new NumberRangeQuery() - { Field = fieldName }; + var variant = new NumberRangeQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -98,7 +95,6 @@ public override NumberRangeQuery Read(ref Utf8JsonReader reader, Type typeToConv } } - reader.Read(); reader.Read(); return variant; } @@ -106,7 +102,7 @@ public override NumberRangeQuery Read(ref Utf8JsonReader reader, Type typeToConv public override void Write(Utf8JsonWriter writer, NumberRangeQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize NumberRangeQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -171,13 +167,20 @@ public override void Write(Utf8JsonWriter writer, NumberRangeQuery value, JsonSe return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(NumberRangeQueryConverter))] - public sealed partial class NumberRangeQuery : Query, IQueryVariant + public sealed partial class NumberRangeQuery : Query { + public NumberRangeQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public float? Boost { get; set; } @@ -196,21 +199,35 @@ public sealed partial class NumberRangeQuery : Query, IQueryVariant public double? To { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class NumberRangeQueryDescriptor : SerializableDescriptorBase> { internal NumberRangeQueryDescriptor(Action> configure) => configure.Invoke(this); - public NumberRangeQueryDescriptor() : base() + internal NumberRangeQueryDescriptor() : base() + { + } + + public NumberRangeQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public NumberRangeQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private double? FromValue { get; set; } @@ -238,7 +255,7 @@ public NumberRangeQueryDescriptor Boost(float? boost) return Self; } - public NumberRangeQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public NumberRangeQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -294,6 +311,8 @@ public NumberRangeQueryDescriptor To(double? to) 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(); @@ -359,15 +378,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class NumberRangeQueryDescriptor : SerializableDescriptorBase { internal NumberRangeQueryDescriptor(Action configure) => configure.Invoke(this); - public NumberRangeQueryDescriptor() : base() + internal NumberRangeQueryDescriptor() : base() { } + public NumberRangeQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private double? FromValue { get; set; } @@ -395,7 +421,7 @@ public NumberRangeQueryDescriptor Boost(float? boost) return Self; } - public NumberRangeQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public NumberRangeQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -457,6 +483,8 @@ public NumberRangeQueryDescriptor To(double? to) 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(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ParentIdQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ParentIdQuery.g.cs index f74538b0fd1..40ce0096d23 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ParentIdQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ParentIdQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class ParentIdQuery : Query, IQueryVariant + public sealed partial class ParentIdQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PercolateQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PercolateQuery.g.cs index 3559677dac9..ec100f28797 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PercolateQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PercolateQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class PercolateQuery : Query, IQueryVariant + public sealed partial class PercolateQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationPostFeatureUpgradeRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedDoc.g.cs similarity index 55% rename from src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationPostFeatureUpgradeRequest.g.cs rename to src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedDoc.g.cs index 9b79a8e4076..83aa5429cb6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Migration/MigrationPostFeatureUpgradeRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedDoc.g.cs @@ -15,7 +15,6 @@ // // ------------------------------------------------ -using Elastic.Transport; using System; using System.Collections.Generic; using System.Linq.Expressions; @@ -23,31 +22,50 @@ using System.Text.Json.Serialization; #nullable restore -namespace Elastic.Clients.Elasticsearch.Migration +namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed class MigrationPostFeatureUpgradeRequestParameters : RequestParameters + public sealed partial class PinnedDoc { - } + [JsonInclude] + [JsonPropertyName("_id")] + public Elastic.Clients.Elasticsearch.Id Id { get; set; } - public sealed partial class MigrationPostFeatureUpgradeRequest : PlainRequestBase - { - internal override ApiUrls ApiUrls => ApiUrlsLookups.MigrationPostFeatureUpgrade; - protected override HttpMethod HttpMethod => HttpMethod.POST; - protected override bool SupportsBody => false; + [JsonInclude] + [JsonPropertyName("_index")] + public Elastic.Clients.Elasticsearch.IndexName Index { get; set; } } - public sealed partial class MigrationPostFeatureUpgradeRequestDescriptor : RequestDescriptorBase + public sealed partial class PinnedDocDescriptor : SerializableDescriptorBase { - internal MigrationPostFeatureUpgradeRequestDescriptor(Action configure) => configure.Invoke(this); - public MigrationPostFeatureUpgradeRequestDescriptor() + internal PinnedDocDescriptor(Action configure) => configure.Invoke(this); + public PinnedDocDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.Id IdValue { get; set; } + + private Elastic.Clients.Elasticsearch.IndexName IndexValue { get; set; } + + public PinnedDocDescriptor Id(Elastic.Clients.Elasticsearch.Id id) + { + IdValue = id; + return Self; + } + + public PinnedDocDescriptor Index(Elastic.Clients.Elasticsearch.IndexName index) { + IndexValue = index; + return Self; } - internal override ApiUrls ApiUrls => ApiUrlsLookups.MigrationPostFeatureUpgrade; - protected override HttpMethod HttpMethod => HttpMethod.POST; - protected override bool SupportsBody => false; protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { + writer.WriteStartObject(); + writer.WritePropertyName("_id"); + JsonSerializer.Serialize(writer, IdValue, options); + writer.WritePropertyName("_index"); + JsonSerializer.Serialize(writer, IndexValue, options); + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedQuery.g.cs index 17e7dfb7f01..ecb5213f9af 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedQuery.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public interface IPinnedQueryVariant - { - } - [JsonConverter(typeof(PinnedQueryConverter))] - public sealed partial class PinnedQuery : Query, IQueryVariant + public sealed partial class PinnedQuery : Query { - public PinnedQuery(string variantName, IPinnedQueryVariant variant) + internal PinnedQuery(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,10 +39,12 @@ public PinnedQuery(string variantName, IPinnedQueryVariant variant) Variant = variant; } - internal IPinnedQueryVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } + public static PinnedQuery Docs(IEnumerable variant) => new PinnedQuery("docs", variant); + public static PinnedQuery Ids(IEnumerable variant) => new PinnedQuery("ids", variant); [JsonInclude] [JsonPropertyName("_name")] public string? QueryName { get; set; } @@ -69,21 +67,96 @@ public override PinnedQuery Read(ref Utf8JsonReader reader, Type typeToConvert, throw new JsonException("Expected start token."); } - reader.Read(); - if (reader.TokenType != JsonTokenType.PropertyName) + object? variantValue = default; + string? variantNameValue = default; + string? nameValue = default; + float? boostValue = default; + Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer organicValue = default; + while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { - throw new JsonException("Expected property name token."); + if (reader.TokenType != JsonTokenType.PropertyName) + { + throw new JsonException("Expected a property name token."); + } + + if (reader.TokenType != JsonTokenType.PropertyName) + { + throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); + } + + var propertyName = reader.GetString(); + reader.Read(); + if (propertyName == "_name") + { + nameValue = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (propertyName == "boost") + { + boostValue = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (propertyName == "organic") + { + organicValue = JsonSerializer.Deserialize(ref reader, options); + continue; + } + + if (propertyName == "docs") + { + variantValue = JsonSerializer.Deserialize?>(ref reader, options); + variantNameValue = propertyName; + continue; + } + + if (propertyName == "ids") + { + variantValue = JsonSerializer.Deserialize?>(ref reader, options); + variantNameValue = propertyName; + continue; + } + + throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'PinnedQuery' from the response."); } - var propertyName = reader.GetString(); reader.Read(); - throw new JsonException(); + var result = new PinnedQuery(variantNameValue, variantValue); + result.QueryName = nameValue; + result.Boost = boostValue; + result.Organic = organicValue; + return result; } public override void Write(Utf8JsonWriter writer, PinnedQuery value, JsonSerializerOptions options) { writer.WriteStartObject(); + if (!string.IsNullOrEmpty(value.QueryName)) + { + writer.WritePropertyName("_name"); + writer.WriteStringValue(value.QueryName); + } + + if (value.Boost.HasValue) + { + writer.WritePropertyName("boost"); + writer.WriteNumberValue(value.Boost.Value); + } + + writer.WritePropertyName("organic"); + JsonSerializer.Serialize(writer, value.Organic, options); writer.WritePropertyName(value.VariantName); + switch (value.VariantName) + { + case "docs": + JsonSerializer.Serialize>(writer, (IEnumerable)value.Variant, options); + break; + case "ids": + JsonSerializer.Serialize>(writer, (IEnumerable)value.Variant, options); + break; + } + writer.WriteEndObject(); } } @@ -95,38 +168,81 @@ public PinnedQueryDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal PinnedQuery Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the PinnedQueryDescriptor. Only a single PinnedQuery variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IPinnedQueryVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new PinnedQuery(variantName, variant); + throw new Exception("A variant has already been assigned to the PinnedQueryDescriptor. Only a single PinnedQuery variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + private Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer OrganicValue { get; set; } + + private QueryContainerDescriptor OrganicDescriptor { get; set; } + + private Action> OrganicDescriptorAction { get; set; } + + private string? QueryNameValue { get; set; } + + private float? BoostValue { get; set; } + + public PinnedQueryDescriptor Organic(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer organic) + { + OrganicDescriptor = null; + OrganicDescriptorAction = null; + OrganicValue = organic; + return Self; + } + + public PinnedQueryDescriptor Organic(QueryContainerDescriptor descriptor) + { + OrganicValue = null; + OrganicDescriptorAction = null; + OrganicDescriptor = descriptor; + return Self; + } + + public PinnedQueryDescriptor Organic(Action> configure) + { + OrganicValue = null; + OrganicDescriptor = null; + OrganicDescriptorAction = configure; + return Self; + } + + public PinnedQueryDescriptor QueryName(string? queryName) + { + QueryNameValue = queryName; + return Self; + } + + public PinnedQueryDescriptor Boost(float? boost) + { + BoostValue = boost; + return Self; + } + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -135,15 +251,45 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + if (OrganicDescriptor is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + writer.WritePropertyName("organic"); + JsonSerializer.Serialize(writer, OrganicDescriptor, options); + } + else if (OrganicDescriptorAction is not null) + { + writer.WritePropertyName("organic"); + JsonSerializer.Serialize(writer, new QueryContainerDescriptor(OrganicDescriptorAction), options); + } + else + { + writer.WritePropertyName("organic"); + JsonSerializer.Serialize(writer, OrganicValue, options); + } + + if (!string.IsNullOrEmpty(QueryNameValue)) + { + writer.WritePropertyName("_name"); + writer.WriteStringValue(QueryNameValue); + } + + if (BoostValue.HasValue) + { + writer.WritePropertyName("boost"); + writer.WriteNumberValue(BoostValue.Value); } - writer.WriteStartObject(); writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + writer.WriteEndObject(); } } @@ -155,38 +301,81 @@ public PinnedQueryDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal PinnedQuery Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the PinnedQueryDescriptor. Only a single PinnedQuery variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IPinnedQueryVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new PinnedQuery(variantName, variant); + throw new Exception("A variant has already been assigned to the PinnedQueryDescriptor. Only a single PinnedQuery variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + private Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer OrganicValue { get; set; } + + private QueryContainerDescriptor OrganicDescriptor { get; set; } + + private Action OrganicDescriptorAction { get; set; } + + private string? QueryNameValue { get; set; } + + private float? BoostValue { get; set; } + + public PinnedQueryDescriptor Organic(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer organic) + { + OrganicDescriptor = null; + OrganicDescriptorAction = null; + OrganicValue = organic; + return Self; + } + + public PinnedQueryDescriptor Organic(QueryContainerDescriptor descriptor) + { + OrganicValue = null; + OrganicDescriptorAction = null; + OrganicDescriptor = descriptor; + return Self; + } + + public PinnedQueryDescriptor Organic(Action configure) + { + OrganicValue = null; + OrganicDescriptor = null; + OrganicDescriptorAction = configure; + return Self; + } + + public PinnedQueryDescriptor QueryName(string? queryName) + { + QueryNameValue = queryName; + return Self; + } + + public PinnedQueryDescriptor Boost(float? boost) + { + BoostValue = boost; + return Self; + } + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -195,15 +384,45 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + if (OrganicDescriptor is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + writer.WritePropertyName("organic"); + JsonSerializer.Serialize(writer, OrganicDescriptor, options); + } + else if (OrganicDescriptorAction is not null) + { + writer.WritePropertyName("organic"); + JsonSerializer.Serialize(writer, new QueryContainerDescriptor(OrganicDescriptorAction), options); + } + else + { + writer.WritePropertyName("organic"); + JsonSerializer.Serialize(writer, OrganicValue, options); + } + + if (!string.IsNullOrEmpty(QueryNameValue)) + { + writer.WritePropertyName("_name"); + writer.WriteStringValue(QueryNameValue); + } + + if (BoostValue.HasValue) + { + writer.WritePropertyName("boost"); + writer.WriteNumberValue(BoostValue.Value); } - writer.WriteStartObject(); writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PrefixQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PrefixQuery.g.cs index b9ebdf266b2..8c87f6a538c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PrefixQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PrefixQuery.g.cs @@ -31,12 +31,9 @@ public override PrefixQuery Read(ref Utf8JsonReader reader, Type typeToConvert, if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new PrefixQuery() - { Field = fieldName }; + var variant = new PrefixQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -74,7 +71,6 @@ public override PrefixQuery Read(ref Utf8JsonReader reader, Type typeToConvert, } } - reader.Read(); reader.Read(); return variant; } @@ -82,7 +78,7 @@ public override PrefixQuery Read(ref Utf8JsonReader reader, Type typeToConvert, public override void Write(Utf8JsonWriter writer, PrefixQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize PrefixQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -119,13 +115,20 @@ public override void Write(Utf8JsonWriter writer, PrefixQuery value, JsonSeriali return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(PrefixQueryConverter))] - public sealed partial class PrefixQuery : Query, IQueryVariant + public sealed partial class PrefixQuery : Query { + public PrefixQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public float? Boost { get; set; } @@ -136,14 +139,28 @@ public sealed partial class PrefixQuery : Query, IQueryVariant public string Value { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class PrefixQueryDescriptor : SerializableDescriptorBase> { internal PrefixQueryDescriptor(Action> configure) => configure.Invoke(this); - public PrefixQueryDescriptor() : base() + internal PrefixQueryDescriptor() : base() + { + } + + public PrefixQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public PrefixQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } @@ -152,7 +169,7 @@ public PrefixQueryDescriptor() : base() private bool? CaseInsensitiveValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string? RewriteValue { get; set; } @@ -176,7 +193,7 @@ public PrefixQueryDescriptor CaseInsensitive(bool? caseInsensitive = return Self; } - public PrefixQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public PrefixQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -202,6 +219,8 @@ public PrefixQueryDescriptor Value(string value) 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(); @@ -239,17 +258,24 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class PrefixQueryDescriptor : SerializableDescriptorBase { internal PrefixQueryDescriptor(Action configure) => configure.Invoke(this); - public PrefixQueryDescriptor() : base() + internal PrefixQueryDescriptor() : base() { } + public PrefixQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } private bool? CaseInsensitiveValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string? RewriteValue { get; set; } @@ -273,7 +299,7 @@ public PrefixQueryDescriptor CaseInsensitive(bool? caseInsensitive = true) return Self; } - public PrefixQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public PrefixQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -305,6 +331,8 @@ public PrefixQueryDescriptor Value(string value) 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(); 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 f28a37c44d6..6b8eea7365d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public interface IQueryVariant - { - } - [JsonConverter(typeof(QueryContainerConverter))] public sealed partial class QueryContainer { - public QueryContainer(string variantName, IQueryVariant variant) + internal QueryContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public QueryContainer(string variantName, IQueryVariant variant) Variant = variant; } - internal IQueryVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -64,7 +60,6 @@ public QueryContainer(string variantName, IQueryVariant variant) public static QueryContainer HasParent(Elastic.Clients.Elasticsearch.QueryDsl.HasParentQuery hasParentQuery) => new QueryContainer("has_parent", hasParentQuery); public static QueryContainer Ids(Elastic.Clients.Elasticsearch.QueryDsl.IdsQuery idsQuery) => new QueryContainer("ids", idsQuery); public static QueryContainer Intervals(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsQuery intervalsQuery) => new QueryContainer("intervals", intervalsQuery); - public static QueryContainer Knn(Elastic.Clients.Elasticsearch.QueryDsl.KnnQuery knnQuery) => new QueryContainer("knn", knnQuery); public static QueryContainer Match(Elastic.Clients.Elasticsearch.QueryDsl.MatchQuery matchQuery) => new QueryContainer("match", matchQuery); public static QueryContainer MatchAll(Elastic.Clients.Elasticsearch.QueryDsl.MatchAllQuery matchAllQuery) => new QueryContainer("match_all", matchAllQuery); public static QueryContainer MatchBoolPrefix(Elastic.Clients.Elasticsearch.QueryDsl.MatchBoolPrefixQuery matchBoolPrefixQuery) => new QueryContainer("match_bool_prefix", matchBoolPrefixQuery); @@ -105,323 +100,373 @@ internal sealed class QueryContainerConverter : JsonConverter { public override QueryContainer Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - var readerCopy = reader; - readerCopy.Read(); - if (readerCopy.TokenType != JsonTokenType.PropertyName) + if (reader.TokenType != JsonTokenType.StartObject) + { + throw new JsonException("Expected start token."); + } + + reader.Read(); + if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException(); + throw new JsonException("Expected a property name token representing the variant held within this container."); } - var propertyName = readerCopy.GetString(); + var propertyName = reader.GetString(); + reader.Read(); if (propertyName == "bool") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "boosting") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "combined_fields") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "constant_score") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "dis_max") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "exists") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "field_masking_span") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "function_score") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "fuzzy") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "geo_bounding_box") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "geo_distance") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "geo_polygon") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "geo_shape") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "has_child") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "has_parent") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "ids") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "intervals") { var variant = JsonSerializer.Deserialize(ref reader, options); - return new QueryContainer(propertyName, variant); - } - - if (propertyName == "knn") - { - var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "match") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "match_all") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "match_bool_prefix") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "match_none") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "match_phrase") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "match_phrase_prefix") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "more_like_this") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "multi_match") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "nested") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "parent_id") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "percolate") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "pinned") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "prefix") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "query_string") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "range") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "rank_feature") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "regexp") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "script") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "script_score") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); 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); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "span_containing") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "span_first") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "span_multi") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "span_near") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "span_not") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "span_or") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "span_term") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "span_within") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "term") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "terms") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "terms_set") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "wildcard") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } if (propertyName == "wrapper") { var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); return new QueryContainer(propertyName, variant); } @@ -485,9 +530,6 @@ public override void Write(Utf8JsonWriter writer, QueryContainer value, JsonSeri case "intervals": JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsQuery)value.Variant, options); break; - case "knn": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.KnnQuery)value.Variant, options); - break; case "match": JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchQuery)value.Variant, options); break; @@ -603,58 +645,35 @@ public QueryContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal QueryContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the QueryContainerDescriptor. Only a single QueryContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IQueryVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new QueryContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the QueryContainerDescriptor. Only a single QueryContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } - - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } - - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); - } - public void Bool(BoolQuery query) => Set(query, "bool"); public void Bool(Action> configure) => Set(configure, "bool"); public void Boosting(BoostingQuery query) => Set(query, "boosting"); @@ -689,8 +708,6 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void Ids(Action configure) => Set(configure, "ids"); public void Intervals(IntervalsQuery query) => Set(query, "intervals"); public void Intervals(Action> configure) => Set(configure, "intervals"); - public void Knn(KnnQuery query) => Set(query, "knn"); - public void Knn(Action> configure) => Set(configure, "knn"); public void Match(MatchQuery query) => Set(query, "match"); public void Match(Action> configure) => Set(configure, "match"); public void MatchAll(MatchAllQuery query) => Set(query, "match_all"); @@ -758,6 +775,27 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void Wildcard(Action> configure) => Set(configure, "wildcard"); public void Wrapper(WrapperQuery query) => Set(query, "wrapper"); public void Wrapper(Action configure) => Set(configure, "wrapper"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } public sealed partial class QueryContainerDescriptor : SerializableDescriptorBase @@ -767,58 +805,35 @@ public QueryContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal QueryContainer Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the QueryContainerDescriptor. Only a single QueryContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IQueryVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new QueryContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the QueryContainerDescriptor. Only a single QueryContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } - - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } - - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); - } - public void Bool(BoolQuery query) => Set(query, "bool"); public void Bool(Action configure) => Set(configure, "bool"); public void Bool(Action> configure) => Set(configure, "bool"); @@ -869,9 +884,6 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void Intervals(IntervalsQuery query) => Set(query, "intervals"); public void Intervals(Action configure) => Set(configure, "intervals"); public void Intervals(Action> configure) => Set(configure, "intervals"); - public void Knn(KnnQuery query) => Set(query, "knn"); - public void Knn(Action configure) => Set(configure, "knn"); - public void Knn(Action> configure) => Set(configure, "knn"); public void Match(MatchQuery query) => Set(query, "match"); public void Match(Action configure) => Set(configure, "match"); public void Match(Action> configure) => Set(configure, "match"); @@ -967,5 +979,26 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void Wildcard(Action> configure) => Set(configure, "wildcard"); public void Wrapper(WrapperQuery query) => Set(query, "wrapper"); public void Wrapper(Action configure) => Set(configure, "wrapper"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryStringQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryStringQuery.g.cs index 2103c68240d..14376b8430f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryStringQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryStringQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class QueryStringQuery : Query, IQueryVariant + public sealed partial class QueryStringQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RandomScoreFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RandomScoreFunction.g.cs index 5f06a12a4f6..907dbffbe9a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RandomScoreFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RandomScoreFunction.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class RandomScoreFunction : IFunctionScoreVariant + public sealed partial class RandomScoreFunction { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RangeQuery.g.cs index 6b60614732c..df8a73eec71 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RangeQuery.g.cs @@ -25,7 +25,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public partial class RangeQuery : Union, IQueryVariant + public partial class RangeQuery : Union { public RangeQuery(Elastic.Clients.Elasticsearch.QueryDsl.DateRangeQuery dateRangeQuery) : base(dateRangeQuery) { diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RankFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RankFeatureQuery.g.cs index 6275cbe9b36..ca88137cbc5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RankFeatureQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RankFeatureQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class RankFeatureQuery : Query, IQueryVariant + public sealed partial class RankFeatureQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RegexpQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RegexpQuery.g.cs index 9d2314cb9a3..72d5e291463 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RegexpQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RegexpQuery.g.cs @@ -31,12 +31,9 @@ public override RegexpQuery Read(ref Utf8JsonReader reader, Type typeToConvert, if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new RegexpQuery() - { Field = fieldName }; + var variant = new RegexpQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -86,7 +83,6 @@ public override RegexpQuery Read(ref Utf8JsonReader reader, Type typeToConvert, } } - reader.Read(); reader.Read(); return variant; } @@ -94,7 +90,7 @@ public override RegexpQuery Read(ref Utf8JsonReader reader, Type typeToConvert, public override void Write(Utf8JsonWriter writer, RegexpQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize RegexpQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -143,13 +139,20 @@ public override void Write(Utf8JsonWriter writer, RegexpQuery value, JsonSeriali return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(RegexpQueryConverter))] - public sealed partial class RegexpQuery : Query, IQueryVariant + public sealed partial class RegexpQuery : Query { + public RegexpQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public float? Boost { get; set; } @@ -164,14 +167,28 @@ public sealed partial class RegexpQuery : Query, IQueryVariant public string Value { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class RegexpQueryDescriptor : SerializableDescriptorBase> { internal RegexpQueryDescriptor(Action> configure) => configure.Invoke(this); - public RegexpQueryDescriptor() : base() + internal RegexpQueryDescriptor() : base() + { + } + + public RegexpQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public RegexpQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } @@ -180,7 +197,7 @@ public RegexpQueryDescriptor() : base() private bool? CaseInsensitiveValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string? FlagsValue { get; set; } @@ -208,7 +225,7 @@ public RegexpQueryDescriptor CaseInsensitive(bool? caseInsensitive = return Self; } - public RegexpQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public RegexpQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -246,6 +263,8 @@ public RegexpQueryDescriptor Value(string value) 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(); @@ -295,17 +314,24 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class RegexpQueryDescriptor : SerializableDescriptorBase { internal RegexpQueryDescriptor(Action configure) => configure.Invoke(this); - public RegexpQueryDescriptor() : base() + internal RegexpQueryDescriptor() : base() { } + public RegexpQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } private bool? CaseInsensitiveValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string? FlagsValue { get; set; } @@ -333,7 +359,7 @@ public RegexpQueryDescriptor CaseInsensitive(bool? caseInsensitive = true) return Self; } - public RegexpQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public RegexpQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -377,6 +403,8 @@ public RegexpQueryDescriptor Value(string value) 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(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ScriptQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ScriptQuery.g.cs index df376f869c0..9214e486856 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ScriptQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ScriptQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class ScriptQuery : Query, IQueryVariant + public sealed partial class ScriptQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ScriptScoreFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ScriptScoreFunction.g.cs index 8f2b251277a..db2a2d44725 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ScriptScoreFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ScriptScoreFunction.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class ScriptScoreFunction : IFunctionScoreVariant + public sealed partial class ScriptScoreFunction { [JsonInclude] [JsonPropertyName("script")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ScriptScoreQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ScriptScoreQuery.g.cs index 2ad8fb5c035..cf8a3aca083 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ScriptScoreQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ScriptScoreQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class ScriptScoreQuery : Query, IQueryVariant + public sealed partial class ScriptScoreQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs index eccc5ad06c0..7a87f1886d5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs @@ -101,7 +101,7 @@ public override void Write(Utf8JsonWriter writer, ShapeQuery value, JsonSerializ } [JsonConverter(typeof(ShapeQueryConverter))] - public sealed partial class ShapeQuery : Query, IQueryVariant + public sealed partial class ShapeQuery : Query { public string? QueryName { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs index 9617406f5c4..051da0fe924 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class SimpleQueryStringQuery : Query, IQueryVariant + public sealed partial class SimpleQueryStringQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanContainingQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanContainingQuery.g.cs index e31dcdd45c9..13147f68e46 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanContainingQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanContainingQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class SpanContainingQuery : Query, IQueryVariant, ISpanQueryVariant + public sealed partial class SpanContainingQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanFieldMaskingQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanFieldMaskingQuery.g.cs index 9b3e9077ba7..363981e4a82 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanFieldMaskingQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanFieldMaskingQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class SpanFieldMaskingQuery : Query, IQueryVariant, ISpanQueryVariant + public sealed partial class SpanFieldMaskingQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanFirstQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanFirstQuery.g.cs index b72667e4d13..e9bb548f824 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanFirstQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanFirstQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class SpanFirstQuery : Query, IQueryVariant, ISpanQueryVariant + public sealed partial class SpanFirstQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanMultiTermQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanMultiTermQuery.g.cs index 67af6be18f4..9cc17e10dd5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanMultiTermQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanMultiTermQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class SpanMultiTermQuery : Query, IQueryVariant, ISpanQueryVariant + public sealed partial class SpanMultiTermQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanNearQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanNearQuery.g.cs index 5b6b4176a59..62563821b65 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanNearQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanNearQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class SpanNearQuery : Query, IQueryVariant, ISpanQueryVariant + public sealed partial class SpanNearQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanNotQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanNotQuery.g.cs index b4e0f394e73..be732c53c60 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanNotQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanNotQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class SpanNotQuery : Query, IQueryVariant, ISpanQueryVariant + public sealed partial class SpanNotQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanOrQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanOrQuery.g.cs index 7f3bd1780ee..380e9129ad4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanOrQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanOrQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class SpanOrQuery : Query, IQueryVariant, ISpanQueryVariant + public sealed partial class SpanOrQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanQuery.g.cs index 0b32e38b318..6577dd79255 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanQuery.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public interface ISpanQueryVariant - { - } - [JsonConverter(typeof(SpanQueryConverter))] public sealed partial class SpanQuery : Query { - public SpanQuery(string variantName, ISpanQueryVariant variant) + internal SpanQuery(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public SpanQuery(string variantName, ISpanQueryVariant variant) Variant = variant; } - internal ISpanQueryVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -70,7 +66,7 @@ public override SpanQuery Read(ref Utf8JsonReader reader, Type typeToConvert, Js reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -187,58 +183,35 @@ public SpanQueryDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal SpanQuery Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the SpanQueryDescriptor. Only a single SpanQuery variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(ISpanQueryVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new SpanQuery(variantName, variant); + throw new Exception("A variant has already been assigned to the SpanQueryDescriptor. Only a single SpanQuery variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } - - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } - - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); - } - public void FieldMaskingSpan(SpanFieldMaskingQuery variant) => Set(variant, "field_masking_span"); public void FieldMaskingSpan(Action> configure) => Set(configure, "field_masking_span"); public void SpanContaining(SpanContainingQuery variant) => Set(variant, "span_containing"); @@ -257,6 +230,27 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void SpanTerm(Action> configure) => Set(configure, "span_term"); public void SpanWithin(SpanWithinQuery variant) => Set(variant, "span_within"); public void SpanWithin(Action> configure) => Set(configure, "span_within"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } public sealed partial class SpanQueryDescriptor : SerializableDescriptorBase @@ -266,58 +260,35 @@ public SpanQueryDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal SpanQuery Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the SpanQueryDescriptor. Only a single SpanQuery variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(ISpanQueryVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new SpanQuery(variantName, variant); + throw new Exception("A variant has already been assigned to the SpanQueryDescriptor. Only a single SpanQuery variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - if (!ContainsVariant) - { - writer.WriteNullValue(); - return; - } - - if (Container is not null) - { - JsonSerializer.Serialize(writer, Container, options); - return; - } - - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); - writer.WriteEndObject(); - } - public void FieldMaskingSpan(SpanFieldMaskingQuery variant) => Set(variant, "field_masking_span"); public void FieldMaskingSpan(Action configure) => Set(configure, "field_masking_span"); public void FieldMaskingSpan(Action> configure) => Set(configure, "field_masking_span"); @@ -345,5 +316,26 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public void SpanWithin(SpanWithinQuery variant) => Set(variant, "span_within"); public void SpanWithin(Action configure) => Set(configure, "span_within"); public void SpanWithin(Action> configure) => Set(configure, "span_within"); + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + if (!ContainsVariant) + { + writer.WriteNullValue(); + return; + } + + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) + { + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + } + + writer.WriteEndObject(); + } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanTermQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanTermQuery.g.cs index fb3ed43cbf7..d697033052b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanTermQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanTermQuery.g.cs @@ -31,12 +31,9 @@ public override SpanTermQuery Read(ref Utf8JsonReader reader, Type typeToConvert if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new SpanTermQuery() - { Field = fieldName }; + var variant = new SpanTermQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -62,7 +59,6 @@ public override SpanTermQuery Read(ref Utf8JsonReader reader, Type typeToConvert } } - reader.Read(); reader.Read(); return variant; } @@ -70,7 +66,7 @@ public override SpanTermQuery Read(ref Utf8JsonReader reader, Type typeToConvert public override void Write(Utf8JsonWriter writer, SpanTermQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize SpanTermQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -95,34 +91,55 @@ public override void Write(Utf8JsonWriter writer, SpanTermQuery value, JsonSeria return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(SpanTermQueryConverter))] - public sealed partial class SpanTermQuery : Query, IQueryVariant, ISpanQueryVariant + public sealed partial class SpanTermQuery : Query { + public SpanTermQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public float? Boost { get; set; } public string Value { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class SpanTermQueryDescriptor : SerializableDescriptorBase> { internal SpanTermQueryDescriptor(Action> configure) => configure.Invoke(this); - public SpanTermQueryDescriptor() : base() + internal SpanTermQueryDescriptor() : base() + { + } + + public SpanTermQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public SpanTermQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string ValueValue { get; set; } @@ -138,7 +155,7 @@ public SpanTermQueryDescriptor Boost(float? boost) return Self; } - public SpanTermQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public SpanTermQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -158,6 +175,8 @@ public SpanTermQueryDescriptor Value(string value) 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(); @@ -183,15 +202,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class SpanTermQueryDescriptor : SerializableDescriptorBase { internal SpanTermQueryDescriptor(Action configure) => configure.Invoke(this); - public SpanTermQueryDescriptor() : base() + internal SpanTermQueryDescriptor() : base() { } + public SpanTermQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string ValueValue { get; set; } @@ -207,7 +233,7 @@ public SpanTermQueryDescriptor Boost(float? boost) return Self; } - public SpanTermQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public SpanTermQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -233,6 +259,8 @@ public SpanTermQueryDescriptor Value(string value) 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(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanWithinQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanWithinQuery.g.cs index 29d8dc3efd8..82dc1572212 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanWithinQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanWithinQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class SpanWithinQuery : Query, IQueryVariant, ISpanQueryVariant + public sealed partial class SpanWithinQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermQuery.g.cs index c4b52e8c818..974468ff477 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermQuery.g.cs @@ -31,12 +31,9 @@ public override TermQuery Read(ref Utf8JsonReader reader, Type typeToConvert, Js if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new TermQuery() - { Field = fieldName }; + var variant = new TermQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -68,7 +65,6 @@ public override TermQuery Read(ref Utf8JsonReader reader, Type typeToConvert, Js } } - reader.Read(); reader.Read(); return variant; } @@ -76,7 +72,7 @@ public override TermQuery Read(ref Utf8JsonReader reader, Type typeToConvert, Js public override void Write(Utf8JsonWriter writer, TermQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize TermQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -107,13 +103,20 @@ public override void Write(Utf8JsonWriter writer, TermQuery value, JsonSerialize return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(TermQueryConverter))] - public sealed partial class TermQuery : Query, IQueryVariant + public sealed partial class TermQuery : Query { + public TermQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public float? Boost { get; set; } @@ -122,14 +125,28 @@ public sealed partial class TermQuery : Query, IQueryVariant public object Value { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class TermQueryDescriptor : SerializableDescriptorBase> { internal TermQueryDescriptor(Action> configure) => configure.Invoke(this); - public TermQueryDescriptor() : base() + internal TermQueryDescriptor() : base() + { + } + + public TermQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public TermQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } @@ -138,7 +155,7 @@ public TermQueryDescriptor() : base() private bool? CaseInsensitiveValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private object ValueValue { get; set; } @@ -160,7 +177,7 @@ public TermQueryDescriptor CaseInsensitive(bool? caseInsensitive = tr return Self; } - public TermQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public TermQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -180,6 +197,8 @@ public TermQueryDescriptor Value(object value) 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(); @@ -211,17 +230,24 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class TermQueryDescriptor : SerializableDescriptorBase { internal TermQueryDescriptor(Action configure) => configure.Invoke(this); - public TermQueryDescriptor() : base() + internal TermQueryDescriptor() : base() { } + public TermQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } private bool? CaseInsensitiveValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private object ValueValue { get; set; } @@ -243,7 +269,7 @@ public TermQueryDescriptor CaseInsensitive(bool? caseInsensitive = true) return Self; } - public TermQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public TermQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -269,6 +295,8 @@ public TermQueryDescriptor Value(object value) 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(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQuery.g.cs index ad4398817e0..7a42f0cb13f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQuery.g.cs @@ -89,7 +89,7 @@ public override void Write(Utf8JsonWriter writer, TermsQuery value, JsonSerializ } [JsonConverter(typeof(TermsQueryConverter))] - public sealed partial class TermsQuery : Query, IQueryVariant + public sealed partial class TermsQuery : Query { public string? QueryName { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsSetQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsSetQuery.g.cs index 66f21c34943..1a46c4ae89f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsSetQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsSetQuery.g.cs @@ -31,12 +31,9 @@ public override TermsSetQuery Read(ref Utf8JsonReader reader, Type typeToConvert if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new TermsSetQuery() - { Field = fieldName }; + var variant = new TermsSetQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -74,7 +71,6 @@ public override TermsSetQuery Read(ref Utf8JsonReader reader, Type typeToConvert } } - reader.Read(); reader.Read(); return variant; } @@ -82,7 +78,7 @@ public override TermsSetQuery Read(ref Utf8JsonReader reader, Type typeToConvert public override void Write(Utf8JsonWriter writer, TermsSetQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize TermsSetQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -119,13 +115,20 @@ public override void Write(Utf8JsonWriter writer, TermsSetQuery value, JsonSeria return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(TermsSetQueryConverter))] - public sealed partial class TermsSetQuery : Query, IQueryVariant + public sealed partial class TermsSetQuery : Query { + public TermsSetQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public float? Boost { get; set; } @@ -136,21 +139,35 @@ public sealed partial class TermsSetQuery : Query, IQueryVariant public IEnumerable Terms { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class TermsSetQueryDescriptor : SerializableDescriptorBase> { internal TermsSetQueryDescriptor(Action> configure) => configure.Invoke(this); - public TermsSetQueryDescriptor() : base() + internal TermsSetQueryDescriptor() : base() + { + } + + public TermsSetQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public TermsSetQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private Elastic.Clients.Elasticsearch.Field? MinimumShouldMatchFieldValue { get; set; } @@ -170,7 +187,7 @@ public TermsSetQueryDescriptor Boost(float? boost) return Self; } - public TermsSetQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public TermsSetQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -208,6 +225,8 @@ public TermsSetQueryDescriptor Terms(IEnumerable terms) 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(); @@ -245,15 +264,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class TermsSetQueryDescriptor : SerializableDescriptorBase { internal TermsSetQueryDescriptor(Action configure) => configure.Invoke(this); - public TermsSetQueryDescriptor() : base() + internal TermsSetQueryDescriptor() : base() { } + public TermsSetQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private Elastic.Clients.Elasticsearch.Field? MinimumShouldMatchFieldValue { get; set; } @@ -273,7 +299,7 @@ public TermsSetQueryDescriptor Boost(float? boost) return Self; } - public TermsSetQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public TermsSetQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -323,6 +349,8 @@ public TermsSetQueryDescriptor Terms(IEnumerable terms) 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(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WildcardQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WildcardQuery.g.cs index ec6ff00c9b0..92fc2f942ea 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WildcardQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WildcardQuery.g.cs @@ -31,12 +31,9 @@ public override WildcardQuery Read(ref Utf8JsonReader reader, Type typeToConvert if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException("Unexpected JSON detected."); reader.Read(); - reader.Read(); - reader.Read(); var fieldName = reader.GetString(); reader.Read(); - var variant = new WildcardQuery() - { Field = fieldName }; + var variant = new WildcardQuery(fieldName); while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) { if (reader.TokenType == JsonTokenType.PropertyName) @@ -80,7 +77,6 @@ public override WildcardQuery Read(ref Utf8JsonReader reader, Type typeToConvert } } - reader.Read(); reader.Read(); return variant; } @@ -88,7 +84,7 @@ public override WildcardQuery Read(ref Utf8JsonReader reader, Type typeToConvert public override void Write(Utf8JsonWriter writer, WildcardQuery value, JsonSerializerOptions options) { if (value.Field is null) - writer.WriteNullValue(); + throw new JsonException("Unable to serialize WildcardQuery because the `Field` property is not set. Field name queries must include a valid field name."); if (options.TryGetClientSettings(out var settings)) { writer.WriteStartObject(); @@ -135,13 +131,20 @@ public override void Write(Utf8JsonWriter writer, WildcardQuery value, JsonSeria return; } - throw new JsonException("Unable to retrieve client settings to infer field."); + throw new JsonException("Unable to retrieve client settings required to infer field."); } } [JsonConverter(typeof(WildcardQueryConverter))] - public sealed partial class WildcardQuery : Query, IQueryVariant + public sealed partial class WildcardQuery : Query { + public WildcardQuery(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + Field = field; + } + public string? QueryName { get; set; } public float? Boost { get; set; } @@ -154,14 +157,28 @@ public sealed partial class WildcardQuery : Query, IQueryVariant public string? Wildcard { get; set; } - public Elastic.Clients.Elasticsearch.Field? Field { get; set; } + public Elastic.Clients.Elasticsearch.Field Field { get; set; } } public sealed partial class WildcardQueryDescriptor : SerializableDescriptorBase> { internal WildcardQueryDescriptor(Action> configure) => configure.Invoke(this); - public WildcardQueryDescriptor() : base() + internal WildcardQueryDescriptor() : base() + { + } + + public WildcardQueryDescriptor(Field field) { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + + public WildcardQueryDescriptor(Expression> field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; } private string? QueryNameValue { get; set; } @@ -170,7 +187,7 @@ public WildcardQueryDescriptor() : base() private bool? CaseInsensitiveValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string? RewriteValue { get; set; } @@ -196,7 +213,7 @@ public WildcardQueryDescriptor CaseInsensitive(bool? caseInsensitive return Self; } - public WildcardQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public WildcardQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -228,6 +245,8 @@ public WildcardQueryDescriptor Wildcard(string? wildcard) 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(); @@ -275,17 +294,24 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class WildcardQueryDescriptor : SerializableDescriptorBase { internal WildcardQueryDescriptor(Action configure) => configure.Invoke(this); - public WildcardQueryDescriptor() : base() + internal WildcardQueryDescriptor() : base() { } + public WildcardQueryDescriptor(Field field) + { + if (field is null) + throw new ArgumentNullException(nameof(field)); + FieldValue = field; + } + private string? QueryNameValue { get; set; } private float? BoostValue { get; set; } private bool? CaseInsensitiveValue { get; set; } - private Elastic.Clients.Elasticsearch.Field? FieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private string? RewriteValue { get; set; } @@ -311,7 +337,7 @@ public WildcardQueryDescriptor CaseInsensitive(bool? caseInsensitive = true) return Self; } - public WildcardQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field? field) + public WildcardQueryDescriptor Field(Elastic.Clients.Elasticsearch.Field field) { FieldValue = field; return Self; @@ -349,6 +375,8 @@ public WildcardQueryDescriptor Wildcard(string? wildcard) 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(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WrapperQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WrapperQuery.g.cs index 0076efd9253..e149cc83884 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WrapperQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WrapperQuery.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.QueryDsl { - public sealed partial class WrapperQuery : Query, IQueryVariant + public sealed partial class WrapperQuery : Query { [JsonInclude] [JsonPropertyName("_name")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/ScoreSort.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/ScoreSort.g.cs index 86831f20296..7b191e27762 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/ScoreSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/ScoreSort.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public sealed partial class ScoreSort : ISortOptionsVariant + public sealed partial class ScoreSort { [JsonInclude] [JsonPropertyName("order")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/ScriptSort.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/ScriptSort.g.cs index 07edaf32536..e129db5d720 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/ScriptSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/ScriptSort.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public sealed partial class ScriptSort : ISortOptionsVariant + public sealed partial class ScriptSort { [JsonInclude] [JsonPropertyName("mode")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/SmoothingModelContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/SmoothingModelContainer.g.cs index 944a5aa1ec5..843f21cb595 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/SmoothingModelContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/SmoothingModelContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public interface ISmoothingModelVariant - { - } - [JsonConverter(typeof(SmoothingModelContainerConverter))] public sealed partial class SmoothingModelContainer { - public SmoothingModelContainer(string variantName, ISmoothingModelVariant variant) + internal SmoothingModelContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public SmoothingModelContainer(string variantName, ISmoothingModelVariant varian Variant = variant; } - internal ISmoothingModelVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -64,7 +60,7 @@ public override SmoothingModelContainer Read(ref Utf8JsonReader reader, Type typ reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -121,38 +117,41 @@ public SmoothingModelContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal SmoothingModelContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the SmoothingModelContainerDescriptor. Only a single SmoothingModelContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(ISmoothingModelVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new SmoothingModelContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the SmoothingModelContainerDescriptor. Only a single SmoothingModelContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Laplace(LaplaceSmoothingModel variant) => Set(variant, "laplace"); + public void Laplace(Action configure) => Set(configure, "laplace"); + public void LinearInterpolation(LinearInterpolationSmoothingModel variant) => Set(variant, "linear_interpolation"); + public void LinearInterpolation(Action configure) => Set(configure, "linear_interpolation"); + public void StupidBackoff(StupidBackoffSmoothingModel variant) => Set(variant, "stupid_backoff"); + public void StupidBackoff(Action configure) => Set(configure, "stupid_backoff"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -161,24 +160,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Laplace(LaplaceSmoothingModel variant) => Set(variant, "laplace"); - public void Laplace(Action configure) => Set(configure, "laplace"); - public void LinearInterpolation(LinearInterpolationSmoothingModel variant) => Set(variant, "linear_interpolation"); - public void LinearInterpolation(Action configure) => Set(configure, "linear_interpolation"); - public void StupidBackoff(StupidBackoffSmoothingModel variant) => Set(variant, "stupid_backoff"); - public void StupidBackoff(Action configure) => Set(configure, "stupid_backoff"); } public sealed partial class SmoothingModelContainerDescriptor : SerializableDescriptorBase @@ -188,38 +182,41 @@ public SmoothingModelContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal SmoothingModelContainer Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the SmoothingModelContainerDescriptor. Only a single SmoothingModelContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(ISmoothingModelVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new SmoothingModelContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the SmoothingModelContainerDescriptor. Only a single SmoothingModelContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Laplace(LaplaceSmoothingModel variant) => Set(variant, "laplace"); + public void Laplace(Action configure) => Set(configure, "laplace"); + public void LinearInterpolation(LinearInterpolationSmoothingModel variant) => Set(variant, "linear_interpolation"); + public void LinearInterpolation(Action configure) => Set(configure, "linear_interpolation"); + public void StupidBackoff(StupidBackoffSmoothingModel variant) => Set(variant, "stupid_backoff"); + public void StupidBackoff(Action configure) => Set(configure, "stupid_backoff"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -228,23 +225,18 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Laplace(LaplaceSmoothingModel variant) => Set(variant, "laplace"); - public void Laplace(Action configure) => Set(configure, "laplace"); - public void LinearInterpolation(LinearInterpolationSmoothingModel variant) => Set(variant, "linear_interpolation"); - public void LinearInterpolation(Action configure) => Set(configure, "linear_interpolation"); - public void StupidBackoff(StupidBackoffSmoothingModel variant) => Set(variant, "stupid_backoff"); - public void StupidBackoff(Action configure) => Set(configure, "stupid_backoff"); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/SortOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/SortOptions.g.cs index faa3351186f..b83cc2f663e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/SortOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/SortOptions.g.cs @@ -25,14 +25,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public interface ISortOptionsVariant - { - } - [JsonConverter(typeof(SortOptionsConverter))] public sealed partial class SortOptions { - public SortOptions(string variantName, ISortOptionsVariant variant) + internal SortOptions(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -44,7 +40,7 @@ public SortOptions(string variantName, ISortOptionsVariant variant) Variant = variant; } - public SortOptions(Elastic.Clients.Elasticsearch.Field field, ISortOptionsVariant variant) + internal SortOptions(Elastic.Clients.Elasticsearch.Field field, object variant) { if (field is null) throw new ArgumentNullException(nameof(field)); @@ -54,7 +50,7 @@ public SortOptions(Elastic.Clients.Elasticsearch.Field field, ISortOptionsVarian Variant = variant; } - internal ISortOptionsVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -79,7 +75,7 @@ public override SortOptions Read(ref Utf8JsonReader reader, Type typeToConvert, reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -165,38 +161,43 @@ public SortOptionsDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal SortOptions Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the SortOptionsDescriptor. Only a single SortOptions variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(ISortOptionsVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new SortOptions(variantName, variant); + throw new Exception("A variant has already been assigned to the SortOptionsDescriptor. Only a single SortOptions variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Doc(ScoreSort variant) => Set(variant, "_doc"); + public void Doc(Action configure) => Set(configure, "_doc"); + public void GeoDistance(GeoDistanceSort variant) => Set(variant, "_geo_distance"); + public void GeoDistance(Action> configure) => Set(configure, "_geo_distance"); + public void Score(ScoreSort variant) => Set(variant, "_score"); + public void Score(Action configure) => Set(configure, "_score"); + public void Script(ScriptSort variant) => Set(variant, "_script"); + public void Script(Action> configure) => Set(configure, "_script"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -205,26 +206,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Doc(ScoreSort variant) => Set(variant, "_doc"); - public void Doc(Action configure) => Set(configure, "_doc"); - public void GeoDistance(GeoDistanceSort variant) => Set(variant, "_geo_distance"); - public void GeoDistance(Action> configure) => Set(configure, "_geo_distance"); - public void Score(ScoreSort variant) => Set(variant, "_score"); - public void Score(Action configure) => Set(configure, "_score"); - public void Script(ScriptSort variant) => Set(variant, "_script"); - public void Script(Action> configure) => Set(configure, "_script"); } public sealed partial class SortOptionsDescriptor : SerializableDescriptorBase @@ -234,38 +228,45 @@ public SortOptionsDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal SortOptions Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the SortOptionsDescriptor. Only a single SortOptions variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(ISortOptionsVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new SortOptions(variantName, variant); + throw new Exception("A variant has already been assigned to the SortOptionsDescriptor. Only a single SortOptions variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Doc(ScoreSort variant) => Set(variant, "_doc"); + public void Doc(Action configure) => Set(configure, "_doc"); + public void GeoDistance(GeoDistanceSort variant) => Set(variant, "_geo_distance"); + public void GeoDistance(Action configure) => Set(configure, "_geo_distance"); + public void GeoDistance(Action> configure) => Set(configure, "_geo_distance"); + public void Score(ScoreSort variant) => Set(variant, "_score"); + public void Score(Action configure) => Set(configure, "_score"); + public void Script(ScriptSort variant) => Set(variant, "_script"); + public void Script(Action configure) => Set(configure, "_script"); + public void Script(Action> configure) => Set(configure, "_script"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -274,27 +275,18 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Doc(ScoreSort variant) => Set(variant, "_doc"); - public void Doc(Action configure) => Set(configure, "_doc"); - public void GeoDistance(GeoDistanceSort variant) => Set(variant, "_geo_distance"); - public void GeoDistance(Action configure) => Set(configure, "_geo_distance"); - public void GeoDistance(Action> configure) => Set(configure, "_geo_distance"); - public void Score(ScoreSort variant) => Set(variant, "_score"); - public void Score(Action configure) => Set(configure, "_score"); - public void Script(ScriptSort variant) => Set(variant, "_script"); - public void Script(Action configure) => Set(configure, "_script"); - public void Script(Action> configure) => Set(configure, "_script"); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Source.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Source.g.cs index b848d6f7690..3345e0e24e0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Source.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Source.g.cs @@ -44,7 +44,7 @@ public sealed partial class Source [JsonInclude] [JsonPropertyName("runtime_mappings")] - public Dictionary>? RuntimeMappings { get; set; } + public Dictionary? RuntimeMappings { get; set; } [JsonInclude] [JsonPropertyName("size")] @@ -89,7 +89,7 @@ public SourceDescriptor() : base() private Action RemoteDescriptorAction { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private int? SizeValue { get; set; } @@ -185,9 +185,9 @@ public SourceDescriptor Remote(Action configu return Self; } - public SourceDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public SourceDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -313,7 +313,7 @@ public SourceDescriptor() : base() private Action RemoteDescriptorAction { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } private int? SizeValue { get; set; } @@ -415,9 +415,9 @@ public SourceDescriptor Remote(Action configure) return Self; } - public SourceDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public SourceDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/StupidBackoffSmoothingModel.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/StupidBackoffSmoothingModel.g.cs index 9676907e3ac..8f101b2ff74 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/StupidBackoffSmoothingModel.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/StupidBackoffSmoothingModel.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public sealed partial class StupidBackoffSmoothingModel : ISmoothingModelVariant + public sealed partial class StupidBackoffSmoothingModel { [JsonInclude] [JsonPropertyName("discount")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TermSuggester.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TermSuggester.g.cs index 3ec6db48fa6..93e851cb288 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TermSuggester.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TermSuggester.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch { - public sealed partial class TermSuggester : IFieldSuggesterVariant + public sealed partial class TermSuggester { [JsonInclude] [JsonPropertyName("analyzer")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/PivotGroupByContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/PivotGroupByContainer.g.cs index 43802c37558..5091ca65738 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/PivotGroupByContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/PivotGroupByContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.TransformManagement { - public interface IPivotGroupByVariant - { - } - [JsonConverter(typeof(PivotGroupByContainerConverter))] public sealed partial class PivotGroupByContainer { - public PivotGroupByContainer(string variantName, IPivotGroupByVariant variant) + internal PivotGroupByContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public PivotGroupByContainer(string variantName, IPivotGroupByVariant variant) Variant = variant; } - internal IPivotGroupByVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -64,7 +60,7 @@ public override PivotGroupByContainer Read(ref Utf8JsonReader reader, Type typeT reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -121,38 +117,41 @@ public PivotGroupByContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal PivotGroupByContainer Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the PivotGroupByContainerDescriptor. Only a single PivotGroupByContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IPivotGroupByVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new PivotGroupByContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the PivotGroupByContainerDescriptor. Only a single PivotGroupByContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void DateHistogram(Aggregations.DateHistogramAggregation variant) => Set(variant, "date_histogram"); + public void DateHistogram(Action> configure) => Set(configure, "date_histogram"); + public void Histogram(Aggregations.HistogramAggregation variant) => Set(variant, "histogram"); + public void Histogram(Action> configure) => Set(configure, "histogram"); + public void Terms(Aggregations.TermsAggregation variant) => Set(variant, "terms"); + public void Terms(Action> configure) => Set(configure, "terms"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -161,24 +160,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void DateHistogram(Aggregations.DateHistogramAggregation variant) => Set(variant, "date_histogram"); - public void DateHistogram(Action> configure) => Set(configure, "date_histogram"); - public void Histogram(Aggregations.HistogramAggregation variant) => Set(variant, "histogram"); - public void Histogram(Action> configure) => Set(configure, "histogram"); - public void Terms(Aggregations.TermsAggregation variant) => Set(variant, "terms"); - public void Terms(Action> configure) => Set(configure, "terms"); } public sealed partial class PivotGroupByContainerDescriptor : SerializableDescriptorBase @@ -188,38 +182,44 @@ public PivotGroupByContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } - - internal string ContainedVariantName { get; private set; } + private bool ContainsVariant { get; set; } - internal PivotGroupByContainer Container { get; private set; } + private string ContainedVariantName { get; set; } - internal Descriptor Descriptor { get; private set; } + private object Variant { get; set; } - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the PivotGroupByContainerDescriptor. Only a single PivotGroupByContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IPivotGroupByVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new PivotGroupByContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the PivotGroupByContainerDescriptor. Only a single PivotGroupByContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void DateHistogram(Aggregations.DateHistogramAggregation variant) => Set(variant, "date_histogram"); + public void DateHistogram(Action configure) => Set(configure, "date_histogram"); + public void DateHistogram(Action> configure) => Set(configure, "date_histogram"); + public void Histogram(Aggregations.HistogramAggregation variant) => Set(variant, "histogram"); + public void Histogram(Action configure) => Set(configure, "histogram"); + public void Histogram(Action> configure) => Set(configure, "histogram"); + public void Terms(Aggregations.TermsAggregation variant) => Set(variant, "terms"); + public void Terms(Action configure) => Set(configure, "terms"); + public void Terms(Action> configure) => Set(configure, "terms"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -228,26 +228,18 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void DateHistogram(Aggregations.DateHistogramAggregation variant) => Set(variant, "date_histogram"); - public void DateHistogram(Action configure) => Set(configure, "date_histogram"); - public void DateHistogram(Action> configure) => Set(configure, "date_histogram"); - public void Histogram(Aggregations.HistogramAggregation variant) => Set(variant, "histogram"); - public void Histogram(Action configure) => Set(configure, "histogram"); - public void Histogram(Action> configure) => Set(configure, "histogram"); - public void Terms(Aggregations.TermsAggregation variant) => Set(variant, "terms"); - public void Terms(Action configure) => Set(configure, "terms"); - public void Terms(Action> configure) => Set(configure, "terms"); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/RetentionPolicy.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/RetentionPolicy.g.cs index cc272a67c0c..a7d5afe2d61 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/RetentionPolicy.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/RetentionPolicy.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.TransformManagement { - public sealed partial class RetentionPolicy : IRetentionPolicyVariant + public sealed partial class RetentionPolicy { [JsonInclude] [JsonPropertyName("field")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/RetentionPolicyContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/RetentionPolicyContainer.g.cs index 612ea7df690..a2d39107944 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/RetentionPolicyContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/RetentionPolicyContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.TransformManagement { - public interface IRetentionPolicyVariant - { - } - [JsonConverter(typeof(RetentionPolicyContainerConverter))] public sealed partial class RetentionPolicyContainer { - public RetentionPolicyContainer(string variantName, IRetentionPolicyVariant variant) + internal RetentionPolicyContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public RetentionPolicyContainer(string variantName, IRetentionPolicyVariant vari Variant = variant; } - internal IRetentionPolicyVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -62,7 +58,7 @@ public override RetentionPolicyContainer Read(ref Utf8JsonReader reader, Type ty reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -99,38 +95,37 @@ public RetentionPolicyContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal RetentionPolicyContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the RetentionPolicyContainerDescriptor. Only a single RetentionPolicyContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IRetentionPolicyVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new RetentionPolicyContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the RetentionPolicyContainerDescriptor. Only a single RetentionPolicyContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Time(RetentionPolicy variant) => Set(variant, "time"); + public void Time(Action> configure) => Set(configure, "time"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -139,20 +134,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Time(RetentionPolicy variant) => Set(variant, "time"); - public void Time(Action> configure) => Set(configure, "time"); } public sealed partial class RetentionPolicyContainerDescriptor : SerializableDescriptorBase @@ -162,38 +156,38 @@ public RetentionPolicyContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal RetentionPolicyContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the RetentionPolicyContainerDescriptor. Only a single RetentionPolicyContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(IRetentionPolicyVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new RetentionPolicyContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the RetentionPolicyContainerDescriptor. Only a single RetentionPolicyContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Time(RetentionPolicy variant) => Set(variant, "time"); + public void Time(Action configure) => Set(configure, "time"); + public void Time(Action> configure) => Set(configure, "time"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -202,20 +196,18 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Time(RetentionPolicy variant) => Set(variant, "time"); - public void Time(Action configure) => Set(configure, "time"); - public void Time(Action> configure) => Set(configure, "time"); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/Source.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/Source.g.cs index 764e9534511..b648dd240d3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/Source.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/Source.g.cs @@ -36,7 +36,7 @@ public sealed partial class Source [JsonInclude] [JsonPropertyName("runtime_mappings")] - public Dictionary>? RuntimeMappings { get; set; } + public Dictionary? RuntimeMappings { get; set; } } public sealed partial class SourceDescriptor : SerializableDescriptorBase> @@ -54,7 +54,7 @@ public SourceDescriptor() : base() private Elastic.Clients.Elasticsearch.Indices IndexValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } public SourceDescriptor Query(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? query) { @@ -86,9 +86,9 @@ public SourceDescriptor Index(Elastic.Clients.Elasticsearch.Indices i return Self; } - public SourceDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public SourceDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } @@ -138,7 +138,7 @@ public SourceDescriptor() : base() private Elastic.Clients.Elasticsearch.Indices IndexValue { get; set; } - private Dictionary>? RuntimeMappingsValue { get; set; } + private Dictionary? RuntimeMappingsValue { get; set; } public SourceDescriptor Query(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? query) { @@ -170,9 +170,9 @@ public SourceDescriptor Index(Elastic.Clients.Elasticsearch.Indices index) return Self; } - public SourceDescriptor RuntimeMappings(Func>, FluentDictionary>> selector) + public SourceDescriptor RuntimeMappings(Func, FluentDictionary> selector) { - RuntimeMappingsValue = selector?.Invoke(new FluentDictionary>()); + RuntimeMappingsValue = selector?.Invoke(new FluentDictionary()); return Self; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/SyncContainer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/SyncContainer.g.cs index 3fb8899519e..cf2272a1686 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/SyncContainer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/SyncContainer.g.cs @@ -24,14 +24,10 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.TransformManagement { - public interface ISyncVariant - { - } - [JsonConverter(typeof(SyncContainerConverter))] public sealed partial class SyncContainer { - public SyncContainer(string variantName, ISyncVariant variant) + internal SyncContainer(string variantName, object variant) { if (variantName is null) throw new ArgumentNullException(nameof(variantName)); @@ -43,7 +39,7 @@ public SyncContainer(string variantName, ISyncVariant variant) Variant = variant; } - internal ISyncVariant Variant { get; } + internal object Variant { get; } internal string VariantName { get; } @@ -62,7 +58,7 @@ public override SyncContainer Read(ref Utf8JsonReader reader, Type typeToConvert reader.Read(); if (reader.TokenType != JsonTokenType.PropertyName) { - throw new JsonException("Expected property name token."); + throw new JsonException("Expected a property name token representing the variant held within this container."); } var propertyName = reader.GetString(); @@ -99,38 +95,37 @@ public SyncContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal SyncContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the SyncContainerDescriptor. Only a single SyncContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(ISyncVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new SyncContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the SyncContainerDescriptor. Only a single SyncContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Time(TimeSync variant) => Set(variant, "time"); + public void Time(Action> configure) => Set(configure, "time"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -139,20 +134,19 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Time(TimeSync variant) => Set(variant, "time"); - public void Time(Action> configure) => Set(configure, "time"); } public sealed partial class SyncContainerDescriptor : SerializableDescriptorBase @@ -162,38 +156,38 @@ public SyncContainerDescriptor() : base() { } - internal bool ContainsVariant { get; private set; } + private bool ContainsVariant { get; set; } - internal string ContainedVariantName { get; private set; } + private string ContainedVariantName { get; set; } - internal SyncContainer Container { get; private set; } + private object Variant { get; set; } - internal Descriptor Descriptor { get; private set; } - - internal Type DescriptorType { get; private set; } + private Descriptor Descriptor { get; set; } private void Set(Action descriptorAction, string variantName) - where T : Descriptor, new() + where T : Descriptor { if (ContainsVariant) - throw new Exception("TODO"); + throw new InvalidOperationException("A variant has already been assigned to the SyncContainerDescriptor. Only a single SyncContainer variant can be added to this container type."); ContainedVariantName = variantName; ContainsVariant = true; - DescriptorType = typeof(T); - var descriptor = new T(); + var descriptor = (T)Activator.CreateInstance(typeof(T), true); descriptorAction?.Invoke(descriptor); Descriptor = descriptor; } - private void Set(ISyncVariant variant, string variantName) + private void Set(object variant, string variantName) { if (ContainsVariant) - throw new Exception("TODO"); - Container = new SyncContainer(variantName, variant); + throw new Exception("A variant has already been assigned to the SyncContainerDescriptor. Only a single SyncContainer variant can be added to this container type."); + Variant = variant; ContainedVariantName = variantName; ContainsVariant = true; } + public void Time(TimeSync variant) => Set(variant, "time"); + public void Time(Action configure) => Set(configure, "time"); + public void Time(Action> configure) => Set(configure, "time"); protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { if (!ContainsVariant) @@ -202,20 +196,18 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o return; } - if (Container is not null) + writer.WriteStartObject(); + writer.WritePropertyName(ContainedVariantName); + if (Variant is not null) { - JsonSerializer.Serialize(writer, Container, options); - return; + JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options); + } + else + { + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); } - writer.WriteStartObject(); - writer.WritePropertyName(ContainedVariantName); - JsonSerializer.Serialize(writer, Descriptor, DescriptorType, options); writer.WriteEndObject(); } - - public void Time(TimeSync variant) => Set(variant, "time"); - public void Time(Action configure) => Set(configure, "time"); - public void Time(Action> configure) => Set(configure, "time"); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/TimeSync.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/TimeSync.g.cs index 36954fadccd..c96364900f7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/TimeSync.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TransformManagement/TimeSync.g.cs @@ -24,7 +24,7 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.TransformManagement { - public sealed partial class TimeSync : ISyncVariant + public sealed partial class TimeSync { [JsonInclude] [JsonPropertyName("delay")] diff --git a/src/Playground/packages.lock.json b/src/Playground/packages.lock.json index 3e2bd62c7f1..c2d24de3b4d 100644 --- a/src/Playground/packages.lock.json +++ b/src/Playground/packages.lock.json @@ -73,14 +73,14 @@ "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } }, "elastic.clients.elasticsearch.jsonnetserializer": { "type": "Project", "dependencies": { - "Elastic.Clients.Elasticsearch": "8.0.0", - "Newtonsoft.Json": "13.0.1" + "Elastic.Clients.Elasticsearch": "[8.0.0, )", + "Newtonsoft.Json": "[13.0.1, )" } } } diff --git a/tests/Tests.ClusterLauncher/packages.lock.json b/tests/Tests.ClusterLauncher/packages.lock.json index 4210d944f7a..6010d62a2a7 100644 --- a/tests/Tests.ClusterLauncher/packages.lock.json +++ b/tests/Tests.ClusterLauncher/packages.lock.json @@ -1157,12 +1157,12 @@ }, "xunit": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "XNR3Yz9QTtec16O0aKcO6+baVNpXmOnPUxDkCY97J+8krUYxPvXT1szYYEUdKk4sB8GOI2YbAjRIOm8ZnXRfzQ==", + "resolved": "2.4.2", + "contentHash": "6Mj73Ont3zj2CJuoykVJfE0ZmRwn7C+pTuRP8c4bnaaTFjwNG6tGe0prJ1yIbMe9AHrpDys63ctWacSsFJWK/w==", "dependencies": { - "xunit.analyzers": "0.10.0", - "xunit.assert": "[2.4.1]", - "xunit.core": "[2.4.1]" + "xunit.analyzers": "1.0.0", + "xunit.assert": "2.4.2", + "xunit.core": "[2.4.2]" } }, "xunit.abstractions": { @@ -1172,30 +1172,30 @@ }, "xunit.analyzers": { "type": "Transitive", - "resolved": "0.10.0", - "contentHash": "4/IDFCJfIeg6bix9apmUtIMwvOsiwqdEexeO/R2D4GReIGPLIRODTpId/l4LRSrAJk9lEO3Zx1H0Zx6uohJDNg==" + "resolved": "1.0.0", + "contentHash": "BeO8hEgs/c8Ls2647fPfieMngncvf0D0xYNDfIO59MolxtCtVjFRd6SRc+7tj8VMqkVOuJcnc9eh4ngI2cAmLQ==" }, "xunit.assert": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "O/Oe0BS5RmSsM+LQOb041TzuPo5MdH2Rov+qXGS37X+KFG1Hxz7kopYklM5+1Y+tRGeXrOx5+Xne1RuqLFQoyQ==", + "resolved": "2.4.2", + "contentHash": "pxJISOFjn2XTTi1mcDCkRZrTFb9OtRRCtx2kZFNF51GdReLr1ls2rnyxvAS4JO247K3aNtflvh5Q0346K5BROA==", "dependencies": { "NETStandard.Library": "1.6.1" } }, "xunit.core": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "Zsj5OMU6JasNGERXZy8s72+pcheG6Q15atS5XpZXqAtULuyQiQ6XNnUsp1gyfC6WgqScqMvySiEHmHcOG6Eg0Q==", + "resolved": "2.4.2", + "contentHash": "KB4yGCxNqIVyekhJLXtKSEq6BaXVp/JO3mbGVE1hxypZTLEe7h+sTbAhpA+yZW2dPtXTuiW+C1B2oxxHEkrmOw==", "dependencies": { - "xunit.extensibility.core": "[2.4.1]", - "xunit.extensibility.execution": "[2.4.1]" + "xunit.extensibility.core": "[2.4.2]", + "xunit.extensibility.execution": "[2.4.2]" } }, "xunit.extensibility.core": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "yKZKm/8QNZnBnGZFD9SewkllHBiK0DThybQD/G4PiAmQjKtEZyHi6ET70QPU9KtSMJGRYS6Syk7EyR2EVDU4Kg==", + "resolved": "2.4.2", + "contentHash": "W1BoXTIN1C6kpVSMw25huSet25ky6IAQUNovu3zGOGN/jWnbgSoTyCrlIhmXSg0tH5nEf8q7h3OjNHOjyu5PfA==", "dependencies": { "NETStandard.Library": "1.6.1", "xunit.abstractions": "2.0.3" @@ -1203,56 +1203,56 @@ }, "xunit.extensibility.execution": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "7e/1jqBpcb7frLkB6XDrHCGXAbKN4Rtdb88epYxCSRQuZDRW8UtTfdTEVpdTl8s4T56e07hOBVd4G0OdCxIY2A==", + "resolved": "2.4.2", + "contentHash": "CZmgcKkwpyo8FlupZdWpJCryrAOWLh1FBPG6gmVZuPQkGQsim/oL4PcP4nfrC2hHgXUFtluvaJ0Sp9PQKUMNpg==", "dependencies": { "NETStandard.Library": "1.6.1", - "xunit.extensibility.core": "[2.4.1]" + "xunit.extensibility.core": "[2.4.2]" } }, "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } }, "elastic.clients.elasticsearch.jsonnetserializer": { "type": "Project", "dependencies": { - "Elastic.Clients.Elasticsearch": "8.0.0", - "Newtonsoft.Json": "13.0.1" + "Elastic.Clients.Elasticsearch": "[8.0.0, )", + "Newtonsoft.Json": "[13.0.1, )" } }, "tests.configuration": { "type": "Project", "dependencies": { - "Elastic.Elasticsearch.Managed": "0.3.5" + "Elastic.Elasticsearch.Managed": "[0.3.5, )" } }, "tests.core": { "type": "Project", "dependencies": { - "DiffPlex": "1.4.1", - "Elastic.Clients.Elasticsearch.JsonNetSerializer": "8.0.0", - "Elastic.Elasticsearch.Xunit": "0.3.5", - "FluentAssertions": "5.10.3", - "JunitXml.TestLogger": "3.0.110", - "Microsoft.Bcl.HashCode": "1.1.1", - "Microsoft.NET.Test.Sdk": "17.2.0", - "Nullean.VsTest.Pretty.TestLogger": "0.3.0", - "Proc": "0.6.1", - "Tests.Domain": "8.0.0", - "xunit": "2.4.1" + "DiffPlex": "[1.4.1, )", + "Elastic.Clients.Elasticsearch.JsonNetSerializer": "[8.0.0, )", + "Elastic.Elasticsearch.Xunit": "[0.3.5, )", + "FluentAssertions": "[5.10.3, )", + "JunitXml.TestLogger": "[3.0.110, )", + "Microsoft.Bcl.HashCode": "[1.1.1, )", + "Microsoft.NET.Test.Sdk": "[17.2.0, )", + "Nullean.VsTest.Pretty.TestLogger": "[0.3.0, )", + "Proc": "[0.6.1, )", + "Tests.Domain": "[8.0.0, )", + "xunit": "[2.4.2, )" } }, "tests.domain": { "type": "Project", "dependencies": { - "Bogus": "22.1.2", - "Elastic.Clients.Elasticsearch": "8.0.0", - "Elastic.Elasticsearch.Managed": "0.3.5", - "Newtonsoft.Json": "13.0.1", - "Tests.Configuration": "8.0.0" + "Bogus": "[22.1.2, )", + "Elastic.Clients.Elasticsearch": "[8.0.0, )", + "Elastic.Elasticsearch.Managed": "[0.3.5, )", + "Newtonsoft.Json": "[13.0.1, )", + "Tests.Configuration": "[8.0.0, )" } } }, @@ -2416,12 +2416,12 @@ }, "xunit": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "XNR3Yz9QTtec16O0aKcO6+baVNpXmOnPUxDkCY97J+8krUYxPvXT1szYYEUdKk4sB8GOI2YbAjRIOm8ZnXRfzQ==", + "resolved": "2.4.2", + "contentHash": "6Mj73Ont3zj2CJuoykVJfE0ZmRwn7C+pTuRP8c4bnaaTFjwNG6tGe0prJ1yIbMe9AHrpDys63ctWacSsFJWK/w==", "dependencies": { - "xunit.analyzers": "0.10.0", - "xunit.assert": "[2.4.1]", - "xunit.core": "[2.4.1]" + "xunit.analyzers": "1.0.0", + "xunit.assert": "2.4.2", + "xunit.core": "[2.4.2]" } }, "xunit.abstractions": { @@ -2431,30 +2431,30 @@ }, "xunit.analyzers": { "type": "Transitive", - "resolved": "0.10.0", - "contentHash": "4/IDFCJfIeg6bix9apmUtIMwvOsiwqdEexeO/R2D4GReIGPLIRODTpId/l4LRSrAJk9lEO3Zx1H0Zx6uohJDNg==" + "resolved": "1.0.0", + "contentHash": "BeO8hEgs/c8Ls2647fPfieMngncvf0D0xYNDfIO59MolxtCtVjFRd6SRc+7tj8VMqkVOuJcnc9eh4ngI2cAmLQ==" }, "xunit.assert": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "O/Oe0BS5RmSsM+LQOb041TzuPo5MdH2Rov+qXGS37X+KFG1Hxz7kopYklM5+1Y+tRGeXrOx5+Xne1RuqLFQoyQ==", + "resolved": "2.4.2", + "contentHash": "pxJISOFjn2XTTi1mcDCkRZrTFb9OtRRCtx2kZFNF51GdReLr1ls2rnyxvAS4JO247K3aNtflvh5Q0346K5BROA==", "dependencies": { "NETStandard.Library": "1.6.1" } }, "xunit.core": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "Zsj5OMU6JasNGERXZy8s72+pcheG6Q15atS5XpZXqAtULuyQiQ6XNnUsp1gyfC6WgqScqMvySiEHmHcOG6Eg0Q==", + "resolved": "2.4.2", + "contentHash": "KB4yGCxNqIVyekhJLXtKSEq6BaXVp/JO3mbGVE1hxypZTLEe7h+sTbAhpA+yZW2dPtXTuiW+C1B2oxxHEkrmOw==", "dependencies": { - "xunit.extensibility.core": "[2.4.1]", - "xunit.extensibility.execution": "[2.4.1]" + "xunit.extensibility.core": "[2.4.2]", + "xunit.extensibility.execution": "[2.4.2]" } }, "xunit.extensibility.core": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "yKZKm/8QNZnBnGZFD9SewkllHBiK0DThybQD/G4PiAmQjKtEZyHi6ET70QPU9KtSMJGRYS6Syk7EyR2EVDU4Kg==", + "resolved": "2.4.2", + "contentHash": "W1BoXTIN1C6kpVSMw25huSet25ky6IAQUNovu3zGOGN/jWnbgSoTyCrlIhmXSg0tH5nEf8q7h3OjNHOjyu5PfA==", "dependencies": { "NETStandard.Library": "1.6.1", "xunit.abstractions": "2.0.3" @@ -2462,56 +2462,56 @@ }, "xunit.extensibility.execution": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "7e/1jqBpcb7frLkB6XDrHCGXAbKN4Rtdb88epYxCSRQuZDRW8UtTfdTEVpdTl8s4T56e07hOBVd4G0OdCxIY2A==", + "resolved": "2.4.2", + "contentHash": "CZmgcKkwpyo8FlupZdWpJCryrAOWLh1FBPG6gmVZuPQkGQsim/oL4PcP4nfrC2hHgXUFtluvaJ0Sp9PQKUMNpg==", "dependencies": { "NETStandard.Library": "1.6.1", - "xunit.extensibility.core": "[2.4.1]" + "xunit.extensibility.core": "[2.4.2]" } }, "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } }, "elastic.clients.elasticsearch.jsonnetserializer": { "type": "Project", "dependencies": { - "Elastic.Clients.Elasticsearch": "8.0.0", - "Newtonsoft.Json": "13.0.1" + "Elastic.Clients.Elasticsearch": "[8.0.0, )", + "Newtonsoft.Json": "[13.0.1, )" } }, "tests.configuration": { "type": "Project", "dependencies": { - "Elastic.Elasticsearch.Managed": "0.3.5" + "Elastic.Elasticsearch.Managed": "[0.3.5, )" } }, "tests.core": { "type": "Project", "dependencies": { - "DiffPlex": "1.4.1", - "Elastic.Clients.Elasticsearch.JsonNetSerializer": "8.0.0", - "Elastic.Elasticsearch.Xunit": "0.3.5", - "FluentAssertions": "5.10.3", - "JunitXml.TestLogger": "3.0.110", - "Microsoft.Bcl.HashCode": "1.1.1", - "Microsoft.NET.Test.Sdk": "17.2.0", - "Nullean.VsTest.Pretty.TestLogger": "0.3.0", - "Proc": "0.6.1", - "Tests.Domain": "8.0.0", - "xunit": "2.4.1" + "DiffPlex": "[1.4.1, )", + "Elastic.Clients.Elasticsearch.JsonNetSerializer": "[8.0.0, )", + "Elastic.Elasticsearch.Xunit": "[0.3.5, )", + "FluentAssertions": "[5.10.3, )", + "JunitXml.TestLogger": "[3.0.110, )", + "Microsoft.Bcl.HashCode": "[1.1.1, )", + "Microsoft.NET.Test.Sdk": "[17.2.0, )", + "Nullean.VsTest.Pretty.TestLogger": "[0.3.0, )", + "Proc": "[0.6.1, )", + "Tests.Domain": "[8.0.0, )", + "xunit": "[2.4.2, )" } }, "tests.domain": { "type": "Project", "dependencies": { - "Bogus": "22.1.2", - "Elastic.Clients.Elasticsearch": "8.0.0", - "Elastic.Elasticsearch.Managed": "0.3.5", - "Newtonsoft.Json": "13.0.1", - "Tests.Configuration": "8.0.0" + "Bogus": "[22.1.2, )", + "Elastic.Clients.Elasticsearch": "[8.0.0, )", + "Elastic.Elasticsearch.Managed": "[0.3.5, )", + "Newtonsoft.Json": "[13.0.1, )", + "Tests.Configuration": "[8.0.0, )" } } }, @@ -3675,12 +3675,12 @@ }, "xunit": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "XNR3Yz9QTtec16O0aKcO6+baVNpXmOnPUxDkCY97J+8krUYxPvXT1szYYEUdKk4sB8GOI2YbAjRIOm8ZnXRfzQ==", + "resolved": "2.4.2", + "contentHash": "6Mj73Ont3zj2CJuoykVJfE0ZmRwn7C+pTuRP8c4bnaaTFjwNG6tGe0prJ1yIbMe9AHrpDys63ctWacSsFJWK/w==", "dependencies": { - "xunit.analyzers": "0.10.0", - "xunit.assert": "[2.4.1]", - "xunit.core": "[2.4.1]" + "xunit.analyzers": "1.0.0", + "xunit.assert": "2.4.2", + "xunit.core": "[2.4.2]" } }, "xunit.abstractions": { @@ -3690,30 +3690,30 @@ }, "xunit.analyzers": { "type": "Transitive", - "resolved": "0.10.0", - "contentHash": "4/IDFCJfIeg6bix9apmUtIMwvOsiwqdEexeO/R2D4GReIGPLIRODTpId/l4LRSrAJk9lEO3Zx1H0Zx6uohJDNg==" + "resolved": "1.0.0", + "contentHash": "BeO8hEgs/c8Ls2647fPfieMngncvf0D0xYNDfIO59MolxtCtVjFRd6SRc+7tj8VMqkVOuJcnc9eh4ngI2cAmLQ==" }, "xunit.assert": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "O/Oe0BS5RmSsM+LQOb041TzuPo5MdH2Rov+qXGS37X+KFG1Hxz7kopYklM5+1Y+tRGeXrOx5+Xne1RuqLFQoyQ==", + "resolved": "2.4.2", + "contentHash": "pxJISOFjn2XTTi1mcDCkRZrTFb9OtRRCtx2kZFNF51GdReLr1ls2rnyxvAS4JO247K3aNtflvh5Q0346K5BROA==", "dependencies": { "NETStandard.Library": "1.6.1" } }, "xunit.core": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "Zsj5OMU6JasNGERXZy8s72+pcheG6Q15atS5XpZXqAtULuyQiQ6XNnUsp1gyfC6WgqScqMvySiEHmHcOG6Eg0Q==", + "resolved": "2.4.2", + "contentHash": "KB4yGCxNqIVyekhJLXtKSEq6BaXVp/JO3mbGVE1hxypZTLEe7h+sTbAhpA+yZW2dPtXTuiW+C1B2oxxHEkrmOw==", "dependencies": { - "xunit.extensibility.core": "[2.4.1]", - "xunit.extensibility.execution": "[2.4.1]" + "xunit.extensibility.core": "[2.4.2]", + "xunit.extensibility.execution": "[2.4.2]" } }, "xunit.extensibility.core": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "yKZKm/8QNZnBnGZFD9SewkllHBiK0DThybQD/G4PiAmQjKtEZyHi6ET70QPU9KtSMJGRYS6Syk7EyR2EVDU4Kg==", + "resolved": "2.4.2", + "contentHash": "W1BoXTIN1C6kpVSMw25huSet25ky6IAQUNovu3zGOGN/jWnbgSoTyCrlIhmXSg0tH5nEf8q7h3OjNHOjyu5PfA==", "dependencies": { "NETStandard.Library": "1.6.1", "xunit.abstractions": "2.0.3" @@ -3721,56 +3721,56 @@ }, "xunit.extensibility.execution": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "7e/1jqBpcb7frLkB6XDrHCGXAbKN4Rtdb88epYxCSRQuZDRW8UtTfdTEVpdTl8s4T56e07hOBVd4G0OdCxIY2A==", + "resolved": "2.4.2", + "contentHash": "CZmgcKkwpyo8FlupZdWpJCryrAOWLh1FBPG6gmVZuPQkGQsim/oL4PcP4nfrC2hHgXUFtluvaJ0Sp9PQKUMNpg==", "dependencies": { "NETStandard.Library": "1.6.1", - "xunit.extensibility.core": "[2.4.1]" + "xunit.extensibility.core": "[2.4.2]" } }, "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } }, "elastic.clients.elasticsearch.jsonnetserializer": { "type": "Project", "dependencies": { - "Elastic.Clients.Elasticsearch": "8.0.0", - "Newtonsoft.Json": "13.0.1" + "Elastic.Clients.Elasticsearch": "[8.0.0, )", + "Newtonsoft.Json": "[13.0.1, )" } }, "tests.configuration": { "type": "Project", "dependencies": { - "Elastic.Elasticsearch.Managed": "0.3.5" + "Elastic.Elasticsearch.Managed": "[0.3.5, )" } }, "tests.core": { "type": "Project", "dependencies": { - "DiffPlex": "1.4.1", - "Elastic.Clients.Elasticsearch.JsonNetSerializer": "8.0.0", - "Elastic.Elasticsearch.Xunit": "0.3.5", - "FluentAssertions": "5.10.3", - "JunitXml.TestLogger": "3.0.110", - "Microsoft.Bcl.HashCode": "1.1.1", - "Microsoft.NET.Test.Sdk": "17.2.0", - "Nullean.VsTest.Pretty.TestLogger": "0.3.0", - "Proc": "0.6.1", - "Tests.Domain": "8.0.0", - "xunit": "2.4.1" + "DiffPlex": "[1.4.1, )", + "Elastic.Clients.Elasticsearch.JsonNetSerializer": "[8.0.0, )", + "Elastic.Elasticsearch.Xunit": "[0.3.5, )", + "FluentAssertions": "[5.10.3, )", + "JunitXml.TestLogger": "[3.0.110, )", + "Microsoft.Bcl.HashCode": "[1.1.1, )", + "Microsoft.NET.Test.Sdk": "[17.2.0, )", + "Nullean.VsTest.Pretty.TestLogger": "[0.3.0, )", + "Proc": "[0.6.1, )", + "Tests.Domain": "[8.0.0, )", + "xunit": "[2.4.2, )" } }, "tests.domain": { "type": "Project", "dependencies": { - "Bogus": "22.1.2", - "Elastic.Clients.Elasticsearch": "8.0.0", - "Elastic.Elasticsearch.Managed": "0.3.5", - "Newtonsoft.Json": "13.0.1", - "Tests.Configuration": "8.0.0" + "Bogus": "[22.1.2, )", + "Elastic.Clients.Elasticsearch": "[8.0.0, )", + "Elastic.Elasticsearch.Managed": "[0.3.5, )", + "Newtonsoft.Json": "[13.0.1, )", + "Tests.Configuration": "[8.0.0, )" } } } diff --git a/tests/Tests.Configuration/tests.default.yaml b/tests/Tests.Configuration/tests.default.yaml index 307c4ecfdcd..f0cb38c1948 100644 --- a/tests/Tests.Configuration/tests.default.yaml +++ b/tests/Tests.Configuration/tests.default.yaml @@ -8,7 +8,7 @@ mode: u # the elasticsearch version that should be started # Can be a snapshot version of sonatype or "latest" to get the latest snapshot of sonatype -elasticsearch_version: 8.4.0-SNAPSHOT +elasticsearch_version: 8.5.0-SNAPSHOT # cluster filter allows you to only run the integration tests of a particular cluster (cluster suffix not needed) # cluster_filter: # whether we want to forcefully reseed on the node, if you are starting the tests with a node already running diff --git a/tests/Tests.Core/Tests.Core.csproj b/tests/Tests.Core/Tests.Core.csproj index c21f338e905..c2098dc0432 100644 --- a/tests/Tests.Core/Tests.Core.csproj +++ b/tests/Tests.Core/Tests.Core.csproj @@ -18,7 +18,7 @@ - + diff --git a/tests/Tests.Core/packages.lock.json b/tests/Tests.Core/packages.lock.json index 6f19516b2de..98631b4429a 100644 --- a/tests/Tests.Core/packages.lock.json +++ b/tests/Tests.Core/packages.lock.json @@ -81,13 +81,13 @@ }, "xunit": { "type": "Direct", - "requested": "[2.4.1, )", - "resolved": "2.4.1", - "contentHash": "XNR3Yz9QTtec16O0aKcO6+baVNpXmOnPUxDkCY97J+8krUYxPvXT1szYYEUdKk4sB8GOI2YbAjRIOm8ZnXRfzQ==", + "requested": "[2.4.2, )", + "resolved": "2.4.2", + "contentHash": "6Mj73Ont3zj2CJuoykVJfE0ZmRwn7C+pTuRP8c4bnaaTFjwNG6tGe0prJ1yIbMe9AHrpDys63ctWacSsFJWK/w==", "dependencies": { - "xunit.analyzers": "0.10.0", - "xunit.assert": "[2.4.1]", - "xunit.core": "[2.4.1]" + "xunit.analyzers": "1.0.0", + "xunit.assert": "2.4.2", + "xunit.core": "[2.4.2]" } }, "Bogus": { @@ -1490,30 +1490,30 @@ }, "xunit.analyzers": { "type": "Transitive", - "resolved": "0.10.0", - "contentHash": "4/IDFCJfIeg6bix9apmUtIMwvOsiwqdEexeO/R2D4GReIGPLIRODTpId/l4LRSrAJk9lEO3Zx1H0Zx6uohJDNg==" + "resolved": "1.0.0", + "contentHash": "BeO8hEgs/c8Ls2647fPfieMngncvf0D0xYNDfIO59MolxtCtVjFRd6SRc+7tj8VMqkVOuJcnc9eh4ngI2cAmLQ==" }, "xunit.assert": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "O/Oe0BS5RmSsM+LQOb041TzuPo5MdH2Rov+qXGS37X+KFG1Hxz7kopYklM5+1Y+tRGeXrOx5+Xne1RuqLFQoyQ==", + "resolved": "2.4.2", + "contentHash": "pxJISOFjn2XTTi1mcDCkRZrTFb9OtRRCtx2kZFNF51GdReLr1ls2rnyxvAS4JO247K3aNtflvh5Q0346K5BROA==", "dependencies": { "NETStandard.Library": "1.6.1" } }, "xunit.core": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "Zsj5OMU6JasNGERXZy8s72+pcheG6Q15atS5XpZXqAtULuyQiQ6XNnUsp1gyfC6WgqScqMvySiEHmHcOG6Eg0Q==", + "resolved": "2.4.2", + "contentHash": "KB4yGCxNqIVyekhJLXtKSEq6BaXVp/JO3mbGVE1hxypZTLEe7h+sTbAhpA+yZW2dPtXTuiW+C1B2oxxHEkrmOw==", "dependencies": { - "xunit.extensibility.core": "[2.4.1]", - "xunit.extensibility.execution": "[2.4.1]" + "xunit.extensibility.core": "[2.4.2]", + "xunit.extensibility.execution": "[2.4.2]" } }, "xunit.extensibility.core": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "yKZKm/8QNZnBnGZFD9SewkllHBiK0DThybQD/G4PiAmQjKtEZyHi6ET70QPU9KtSMJGRYS6Syk7EyR2EVDU4Kg==", + "resolved": "2.4.2", + "contentHash": "W1BoXTIN1C6kpVSMw25huSet25ky6IAQUNovu3zGOGN/jWnbgSoTyCrlIhmXSg0tH5nEf8q7h3OjNHOjyu5PfA==", "dependencies": { "NETStandard.Library": "1.6.1", "xunit.abstractions": "2.0.3" @@ -1521,40 +1521,40 @@ }, "xunit.extensibility.execution": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "7e/1jqBpcb7frLkB6XDrHCGXAbKN4Rtdb88epYxCSRQuZDRW8UtTfdTEVpdTl8s4T56e07hOBVd4G0OdCxIY2A==", + "resolved": "2.4.2", + "contentHash": "CZmgcKkwpyo8FlupZdWpJCryrAOWLh1FBPG6gmVZuPQkGQsim/oL4PcP4nfrC2hHgXUFtluvaJ0Sp9PQKUMNpg==", "dependencies": { "NETStandard.Library": "1.6.1", - "xunit.extensibility.core": "[2.4.1]" + "xunit.extensibility.core": "[2.4.2]" } }, "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } }, "elastic.clients.elasticsearch.jsonnetserializer": { "type": "Project", "dependencies": { - "Elastic.Clients.Elasticsearch": "8.0.0", - "Newtonsoft.Json": "13.0.1" + "Elastic.Clients.Elasticsearch": "[8.0.0, )", + "Newtonsoft.Json": "[13.0.1, )" } }, "tests.configuration": { "type": "Project", "dependencies": { - "Elastic.Elasticsearch.Managed": "0.3.5" + "Elastic.Elasticsearch.Managed": "[0.3.5, )" } }, "tests.domain": { "type": "Project", "dependencies": { - "Bogus": "22.1.2", - "Elastic.Clients.Elasticsearch": "8.0.0", - "Elastic.Elasticsearch.Managed": "0.3.5", - "Newtonsoft.Json": "13.0.1", - "Tests.Configuration": "8.0.0" + "Bogus": "[22.1.2, )", + "Elastic.Clients.Elasticsearch": "[8.0.0, )", + "Elastic.Elasticsearch.Managed": "[0.3.5, )", + "Newtonsoft.Json": "[13.0.1, )", + "Tests.Configuration": "[8.0.0, )" } } } diff --git a/tests/Tests.Domain/packages.lock.json b/tests/Tests.Domain/packages.lock.json index 50713ca858f..92da7c735ed 100644 --- a/tests/Tests.Domain/packages.lock.json +++ b/tests/Tests.Domain/packages.lock.json @@ -1084,13 +1084,13 @@ "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } }, "tests.configuration": { "type": "Project", "dependencies": { - "Elastic.Elasticsearch.Managed": "0.3.5" + "Elastic.Elasticsearch.Managed": "[0.3.5, )" } } } diff --git a/tests/Tests/Aggregations/AggregationUsageTestBase.cs b/tests/Tests/Aggregations/AggregationUsageTestBase.cs index 4c4ab38d4af..522cdd21b47 100644 --- a/tests/Tests/Aggregations/AggregationUsageTestBase.cs +++ b/tests/Tests/Aggregations/AggregationUsageTestBase.cs @@ -51,7 +51,7 @@ protected AggregationUsageTestBase(TCluster cluster, EndpointUsage usage) : base protected abstract AggregationDictionary InitializerAggs { get; } - protected virtual QueryContainer QueryScope { get; } = new TermQuery { Field = "type", Value = Project.TypeName }; + protected virtual QueryContainer QueryScope { get; } = new TermQuery("type") { Value = Project.TypeName }; protected virtual object QueryScopeJson { get; } = new { term = new { type = new { value = Project.TypeName } } }; diff --git a/tests/Tests/Document/Multiple/MultiGet/MultiGetApiTests.cs b/tests/Tests/Document/Multiple/MultiGet/MultiGetApiTests.cs deleted file mode 100644 index e4a3ea608f3..00000000000 --- a/tests/Tests/Document/Multiple/MultiGet/MultiGetApiTests.cs +++ /dev/null @@ -1,121 +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. - -using System; -using System.Collections.Generic; -using System.Linq; -using Tests.Core.ManagedElasticsearch.Clusters; -using Tests.Domain; -using Tests.Framework.EndpointTests; -using Tests.Framework.EndpointTests.TestState; - -namespace Tests.Document.Multiple; - -public class MultiGetSimplifiedApiTests - : ApiIntegrationTestBase, MultiGetRequestDescriptor, MultiGetRequest> -{ - private readonly IEnumerable _ids = Developer.Developers.Select(d => d.Id).Take(10); - - public MultiGetSimplifiedApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - - protected override bool ExpectIsValid => true; - - protected override bool VerifyJson => true; - - protected override int ExpectStatusCode => 200; - - protected override Action> Fluent => d => d - .Index(Infer.Index()) - .Docs(_ids.Select>(id => d => d.Id(id)).ToArray()); - - protected override HttpMethod HttpMethod => HttpMethod.POST; - - protected override MultiGetRequest Initializer => new(Infer.Index()) - { - Docs = _ids.Select(id => new Operation { Id = id }) - }; - - protected override bool SupportsDeserialization => false; - - protected override string ExpectedUrlPathAndQuery => "/devs/_mget"; - - protected override LazyResponses ClientUsage() => Calls( - (client, f) => client.MultiGet(f), - (client, f) => client.MultiGetAsync(f), - (client, r) => client.MultiGet(r), - (client, r) => client.MultiGetAsync(r) - ); - - protected override void ExpectResponse(MultiGetResponse response) - { - response.Docs.Should().NotBeEmpty().And.HaveCount(10); - - foreach (var document in response.Docs) - { - var getResult = document.Item1; - var error = document.Item2; - - getResult.Should().NotBeNull(); - getResult.Index.Should().NotBeNullOrWhiteSpace(); - getResult.Id.Should().NotBeNullOrWhiteSpace(); - getResult.Found.Should().BeTrue(); - - error.Should().BeNull(); - } - } -} - -public class MultiGetViaIdsSimplifiedApiTests - : ApiIntegrationTestBase, MultiGetRequestDescriptor, MultiGetRequest> -{ - private readonly IEnumerable _ids = Developer.Developers.Select(d => d.Id).Take(10); - - public MultiGetViaIdsSimplifiedApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - - protected override bool ExpectIsValid => true; - - protected override bool VerifyJson => true; - - protected override int ExpectStatusCode => 200; - - protected override Action> Fluent => d => d - .Index(Infer.Index()) - .Ids(_ids.Select(i => i.ToString()).ToArray()); - - protected override HttpMethod HttpMethod => HttpMethod.POST; - - protected override MultiGetRequest Initializer => new(Infer.Index()) - { - Ids = _ids.Select(i => i.ToString()).ToArray() - }; - - protected override bool SupportsDeserialization => false; - - protected override string ExpectedUrlPathAndQuery => "/devs/_mget"; - - protected override LazyResponses ClientUsage() => Calls( - (client, f) => client.MultiGet(f), - (client, f) => client.MultiGetAsync(f), - (client, r) => client.MultiGet(r), - (client, r) => client.MultiGetAsync(r) - ); - - protected override void ExpectResponse(MultiGetResponse response) - { - response.Docs.Should().NotBeEmpty().And.HaveCount(10); - - foreach (var document in response.Docs) - { - var getResult = document.Item1; - var error = document.Item2; - - getResult.Should().NotBeNull(); - getResult.Index.Should().NotBeNullOrWhiteSpace(); - getResult.Id.Should().NotBeNullOrWhiteSpace(); - getResult.Found.Should().BeTrue(); - - error.Should().BeNull(); - } - } -} diff --git a/tests/Tests/Document/Multiple/MultiSearch/MultiSearchApiTests.cs b/tests/Tests/Document/Multiple/MultiSearch/MultiSearchApiTests.cs deleted file mode 100644 index 263ae526efa..00000000000 --- a/tests/Tests/Document/Multiple/MultiSearch/MultiSearchApiTests.cs +++ /dev/null @@ -1,70 +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. - -using System; -using System.Collections.Generic; -using System.Linq; -using Elastic.Clients.Elasticsearch.QueryDsl; -using Tests.Core.ManagedElasticsearch.Clusters; -using Tests.Domain; -using Tests.Framework.EndpointTests; -using Tests.Framework.EndpointTests.TestState; - -namespace Tests.Document.Multiple; - -public class MultiSearchApiTests - : ApiIntegrationTestBase, MultiSearchRequestDescriptor, MultiSearchRequest> -{ - public MultiSearchApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - - protected override bool ExpectIsValid => true; - - protected override bool SupportsDeserialization => false; - - protected override bool VerifyNdJson => true; - - protected override int ExpectStatusCode => 200; - - // TODO - Fluent API improvements after POC code-gen - protected override Action> Fluent => d => d - .Indices(Infer.Index()) // TODO - Should support fluent verion and ctor with Indices - .AddSearch(new SearchRequestItem(new MultisearchBody { From = 0, Size = 10, Query = new MatchAllQuery() })) - .AddSearch(new SearchRequestItem(new MultisearchBody { From = 0, Size = 1, Query = new MatchAllQuery() })); - - protected override HttpMethod HttpMethod => HttpMethod.POST; - - protected override MultiSearchRequest Initializer => new(Infer.Index()) - { - Searches = new List - { - new SearchRequestItem(new MultisearchBody { From = 0, Size = 10, Query = new MatchAllQuery() }), - new SearchRequestItem(new MultisearchBody { From = 0, Size = 1, Query = new MatchAllQuery() }) - } - }; - - protected override string ExpectedUrlPathAndQuery => "/project/_msearch"; - - protected override LazyResponses ClientUsage() => Calls( - (client, f) => client.MultiSearch(f), - (client, f) => client.MultiSearchAsync(f), - (client, r) => client.MultiSearch(r), - (client, r) => client.MultiSearchAsync(r) - ); - - protected override void ExpectResponse(MultiSearchResponse response) - { - response.Took.Should().BeGreaterThan(0); - response.Responses.Count.Should().Be(2); - - var firstResults = response.Responses.First().Item1; - firstResults.Should().NotBeNull(); - firstResults.Total.Should().Be(100); - firstResults.Documents.Should().HaveCount(10); - - var lastResults = response.Responses.Last().Item1; - lastResults.Should().NotBeNull(); - lastResults.Total.Should().Be(100); - lastResults.Documents.Should().HaveCount(1); - } -} diff --git a/tests/Tests/Search/Count/CountApiTests.cs b/tests/Tests/Search/Count/CountApiTests.cs index 7a24da59f09..77afdb151b8 100644 --- a/tests/Tests/Search/Count/CountApiTests.cs +++ b/tests/Tests/Search/Count/CountApiTests.cs @@ -23,9 +23,8 @@ public CountApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluste protected override int ExpectStatusCode => 200; protected override Action> Fluent => c => c - .Query(QueryContainer.Match(new MatchQuery + .Query(QueryContainer.Match(new MatchQuery("name") { - Field = "name", Query = "NEST" })); @@ -33,9 +32,8 @@ public CountApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluste protected override CountRequest Initializer => new() { - Query = QueryContainer.Match(new MatchQuery + Query = QueryContainer.Match(new MatchQuery("name") { - Field = "name", Query = "NEST" }) }; @@ -65,9 +63,8 @@ public CountApiTests_NonGenericDescriptor(ReadOnlyCluster cluster, EndpointUsage protected override Action Fluent => c => c .Indices("project") - .Query(QueryContainer.Match(new MatchQuery + .Query(QueryContainer.Match(new MatchQuery("name") { - Field = "name", Query = "NEST" })); @@ -75,9 +72,8 @@ public CountApiTests_NonGenericDescriptor(ReadOnlyCluster cluster, EndpointUsage protected override CountRequest Initializer => new() { - Query = QueryContainer.Match(new MatchQuery + Query = QueryContainer.Match(new MatchQuery("name") { - Field = "name", Query = "NEST" }) }; @@ -115,9 +111,8 @@ public CountApi_FluentMatch_ApiTests(ReadOnlyCluster cluster, EndpointUsage usag protected override CountRequest Initializer => new() { - Query = QueryContainer.Match(new MatchQuery + Query = QueryContainer.Match(new MatchQuery("name") { - Field = "name", Query = "NEST" }) }; diff --git a/tests/Tests/Search/Search/SearchApiTests.cs b/tests/Tests/Search/Search/SearchApiTests.cs index b5d944d3201..6d19f064276 100644 --- a/tests/Tests/Search/Search/SearchApiTests.cs +++ b/tests/Tests/Search/Search/SearchApiTests.cs @@ -83,9 +83,8 @@ public SearchApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(clust { Field = "startedOn" }, - PostFilter = new TermQuery + PostFilter = new TermQuery("state") { - Field = "state", Value = "Stable" } }; @@ -248,9 +247,8 @@ public SearchApiStoredFieldsTests(ReadOnlyCluster cluster, EndpointUsage usage) { Field = "startedOn" }, - PostFilter = new TermQuery + PostFilter = new TermQuery("state") { - Field = "state", Value = "Stable" }, StoredFields = Infer.Fields(p => p.Name, p => p.NumberOfCommits) diff --git a/tests/Tests/Search/Search/SearchUsageTestBase.cs b/tests/Tests/Search/Search/SearchUsageTestBase.cs index 52365c2b6cf..ca787c7859f 100644 --- a/tests/Tests/Search/Search/SearchUsageTestBase.cs +++ b/tests/Tests/Search/Search/SearchUsageTestBase.cs @@ -14,9 +14,8 @@ namespace Tests.Search.Search public abstract class SearchUsageTestBase : ApiIntegrationTestBase, SearchRequestDescriptor, SearchRequest> { - protected TermQuery ProjectFilter = new() + protected TermQuery ProjectFilter = new(Field(p => p.Type)) { - Field = Field(p => p.Type), Value = Project.TypeName }; diff --git a/tests/Tests/Serialization/FieldNameQueryConverterTests.cs b/tests/Tests/Serialization/Queries/FieldNameQueryConverterTests.cs similarity index 96% rename from tests/Tests/Serialization/FieldNameQueryConverterTests.cs rename to tests/Tests/Serialization/Queries/FieldNameQueryConverterTests.cs index b2668edc0c7..e4b15365e24 100644 --- a/tests/Tests/Serialization/FieldNameQueryConverterTests.cs +++ b/tests/Tests/Serialization/Queries/FieldNameQueryConverterTests.cs @@ -7,7 +7,7 @@ using Tests.Domain; using VerifyXunit; -namespace Tests.Serialization; +namespace Tests.Serialization.Queries; [UsesVerify] public class QueryContainer_WithFieldNameQuery_SerializationTests : SerializerTestBase diff --git a/tests/Tests/Serialization/Queries/IntervalsQuerySerializationTests.cs b/tests/Tests/Serialization/Queries/IntervalsQuerySerializationTests.cs new file mode 100644 index 00000000000..2cb18f7aebc --- /dev/null +++ b/tests/Tests/Serialization/Queries/IntervalsQuerySerializationTests.cs @@ -0,0 +1,87 @@ +// 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. + +using System.Threading.Tasks; +using Elastic.Clients.Elasticsearch.QueryDsl; +using Tests.Domain; +using VerifyXunit; + +namespace Tests.Serialization; + +[UsesVerify] +public class IntervalsQuerySerializationTests : SerializerTestBase +{ + private readonly IntervalsMatch _intervalsMatch = new() + { + Query = "Steve", + MaxGaps = 0, + Ordered = true + }; + + [U] + public async Task IntervalsQueryDescriptor_CanSerialize() + { + var search = new SearchRequestDescriptor(search => search + .Query(q => q + .Intervals(i => i + .Field(f => f.Name) + .Boost(2.0f) + .QueryName("testing-intervals") + .Match(m => m + .Query("Steve") + .MaxGaps(0) + .Ordered())))); + + var serialisedJson = await SerializeAndGetJsonStringAsync(search); + + await Verifier.VerifyJson(serialisedJson); + } + + [U] + public async Task IntervalsQueryDescriptor_CanSerialize_WithObjectVariant() + { + var search = new SearchRequestDescriptor(search => search + .Query(q => q + .Intervals(i => i + .Field(f => f.Name) + .Boost(2.0f) + .QueryName("testing-intervals") + .Match(_intervalsMatch)))); + + var serialisedJson = await SerializeAndGetJsonStringAsync(search); + + await Verifier.VerifyJson(serialisedJson); + } + + [U] + public async Task IntervalsQuery_CanSerialize() + { + var query = IntervalsQuery.Match(Infer.Field(f => f.Name), _intervalsMatch); + query.QueryName = "testing-intervals"; + query.Boost = 2.0f; + + var search = new SearchRequestDescriptor(search => search + .Query(q => q.Intervals(query))); + + var serialisedJson = await SerializeAndGetJsonStringAsync(search); + + await Verifier.VerifyJson(serialisedJson); + } + + [U] + public void IntervalsQuery_CanDeserialize() + { + var stream = WrapInStream(@"{""intervals"":{""name"":{""boost"":2,""match"":{""max_gaps"":1,""ordered"":true,""query"":""Steve""},""_name"":""testing-intervals""}}}"); + + var queryContainer = _requestResponseSerializer.Deserialize(stream); + var intervalsQuery = queryContainer.Variant.Should().BeOfType().Subject; + + intervalsQuery.Boost.Should().Be(2.0f); + intervalsQuery.QueryName.Should().Be("testing-intervals"); + var intervalsMatch = intervalsQuery.Variant.Should().BeOfType().Subject; + intervalsMatch.Query.Should().Be("Steve"); + intervalsMatch.Ordered.Should().BeTrue(); + intervalsMatch.MaxGaps.Should().Be(1); + } +} diff --git a/tests/Tests/Serialization/Queries/MultipleSearchFiltersTests.cs b/tests/Tests/Serialization/Queries/MultipleSearchFiltersTests.cs index 971311b0fd5..8f31a7bbf20 100644 --- a/tests/Tests/Serialization/Queries/MultipleSearchFiltersTests.cs +++ b/tests/Tests/Serialization/Queries/MultipleSearchFiltersTests.cs @@ -35,7 +35,7 @@ public async Task CanSerialize_DateRangeFilter() .Query(q => q .Bool(b => b .Filter( // TODO - Update once we have fluent unions - f => f.Range(new RangeQuery(new DateRangeQuery { Gte = "now-1d/d", Lt = "now/d", Field = Infer.Field(f => f.LastActivity) })) + f => f.Range(new RangeQuery(new DateRangeQuery(Infer.Field(f => f.LastActivity)) { Gte = "now-1d/d", Lt = "now/d" })) )))); var serialisedJson = await SerializeAndGetJsonStringAsync(search); diff --git a/tests/Tests/Serialization/Queries/SearchSerializationTests.cs b/tests/Tests/Serialization/Queries/SearchSerializationTests.cs index 904a833b456..fc5f7f54a28 100644 --- a/tests/Tests/Serialization/Queries/SearchSerializationTests.cs +++ b/tests/Tests/Serialization/Queries/SearchSerializationTests.cs @@ -15,9 +15,8 @@ public class SearchSerializationTests : SerializerTestBase [U] public async Task Search_WithMatchQuery_SerializesInferredField_ForObjectInitializer() { - var container = QueryContainer.Match(new MatchQuery + var container = QueryContainer.Match(new MatchQuery(Infer.Field(d => d.Description)) { - Field = Infer.Field(d => d.Description), Query = "testing" }); diff --git a/tests/Tests/Tests.csproj b/tests/Tests/Tests.csproj index 89552e42966..544afae381a 100644 --- a/tests/Tests/Tests.csproj +++ b/tests/Tests/Tests.csproj @@ -18,13 +18,13 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/Tests/_VerifySnapshots/IntervalsQuerySerializationTests.IntervalsQueryDescriptor_CanSerialize.verified.txt b/tests/Tests/_VerifySnapshots/IntervalsQuerySerializationTests.IntervalsQueryDescriptor_CanSerialize.verified.txt new file mode 100644 index 00000000000..7a845f270a9 --- /dev/null +++ b/tests/Tests/_VerifySnapshots/IntervalsQuerySerializationTests.IntervalsQueryDescriptor_CanSerialize.verified.txt @@ -0,0 +1,15 @@ +{ + query: { + intervals: { + name: { + boost: 2, + match: { + max_gaps: 0, + ordered: true, + query: Steve + }, + _name: testing-intervals + } + } + } +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/IntervalsQuerySerializationTests.IntervalsQueryDescriptor_CanSerialize_WithObjectVariant.verified.txt b/tests/Tests/_VerifySnapshots/IntervalsQuerySerializationTests.IntervalsQueryDescriptor_CanSerialize_WithObjectVariant.verified.txt new file mode 100644 index 00000000000..7a845f270a9 --- /dev/null +++ b/tests/Tests/_VerifySnapshots/IntervalsQuerySerializationTests.IntervalsQueryDescriptor_CanSerialize_WithObjectVariant.verified.txt @@ -0,0 +1,15 @@ +{ + query: { + intervals: { + name: { + boost: 2, + match: { + max_gaps: 0, + ordered: true, + query: Steve + }, + _name: testing-intervals + } + } + } +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/IntervalsQuerySerializationTests.IntervalsQuery_CanSerialize.verified.txt b/tests/Tests/_VerifySnapshots/IntervalsQuerySerializationTests.IntervalsQuery_CanSerialize.verified.txt new file mode 100644 index 00000000000..7a845f270a9 --- /dev/null +++ b/tests/Tests/_VerifySnapshots/IntervalsQuerySerializationTests.IntervalsQuery_CanSerialize.verified.txt @@ -0,0 +1,15 @@ +{ + query: { + intervals: { + name: { + boost: 2, + match: { + max_gaps: 0, + ordered: true, + query: Steve + }, + _name: testing-intervals + } + } + } +} \ No newline at end of file diff --git a/tests/Tests/packages.lock.json b/tests/Tests/packages.lock.json index a8ffc4e74f2..4db3b352305 100644 --- a/tests/Tests/packages.lock.json +++ b/tests/Tests/packages.lock.json @@ -34,12 +34,12 @@ }, "Microsoft.NET.Test.Sdk": { "type": "Direct", - "requested": "[17.2.0, )", - "resolved": "17.2.0", - "contentHash": "kYmkDYbcDd+jNvmMH4TMtgHjsUYbIsWENM2VcjB0X7TawXbehL5I8OIsu2TgFS/nQCgZE94InrqMxrm7WDy+Lw==", + "requested": "[17.3.1, )", + "resolved": "17.3.1", + "contentHash": "jH9W5uYannaJ3HhrPBkzSidf3WkqP6XI+Yke0ODYVuFWM6GLVtBAyNgXvU/uQXPBsHq4aysLTsrN1FvG2hlKoQ==", "dependencies": { - "Microsoft.CodeCoverage": "17.2.0", - "Microsoft.TestPlatform.TestHost": "17.2.0" + "Microsoft.CodeCoverage": "17.3.1", + "Microsoft.TestPlatform.TestHost": "17.3.1" } }, "Microsoft.NETFramework.ReferenceAssemblies": { @@ -100,25 +100,25 @@ }, "Verify.Xunit": { "type": "Direct", - "requested": "[14.11.4, )", - "resolved": "14.11.4", - "contentHash": "88dGgVGR7znRFRGOouWHfZO1034NqwqoUAMgymgTj5jSrDOhAygboCwX0+Ph8Nwp17Z/GnfyCvAoDrHAyPWd3w==", + "requested": "[17.10.2, )", + "resolved": "17.10.2", + "contentHash": "9k4cmIA15EfWpC0oHgo9gEKHpIizxsXZs4f2y5OGea13gYUPFqa+06ncm6zaU4qL+jAewpX8jRoHVZgNpKW3Gw==", "dependencies": { "EmptyFiles": "2.8.0", - "Verify": "14.11.4", + "Verify": "17.10.2", "xunit.abstractions": "2.0.3", - "xunit.assert": "2.4.1", - "xunit.extensibility.execution": "2.4.1" + "xunit.assert": "2.4.2", + "xunit.extensibility.execution": "2.4.2" } }, "xunit.extensibility.execution": { "type": "Direct", - "requested": "[2.4.1, )", - "resolved": "2.4.1", - "contentHash": "7e/1jqBpcb7frLkB6XDrHCGXAbKN4Rtdb88epYxCSRQuZDRW8UtTfdTEVpdTl8s4T56e07hOBVd4G0OdCxIY2A==", + "requested": "[2.4.2, )", + "resolved": "2.4.2", + "contentHash": "CZmgcKkwpyo8FlupZdWpJCryrAOWLh1FBPG6gmVZuPQkGQsim/oL4PcP4nfrC2hHgXUFtluvaJ0Sp9PQKUMNpg==", "dependencies": { "NETStandard.Library": "1.6.1", - "xunit.extensibility.core": "[2.4.1]" + "xunit.extensibility.core": "[2.4.2]" } }, "xunit.runner.visualstudio": { @@ -129,8 +129,8 @@ }, "DiffEngine": { "type": "Transitive", - "resolved": "8.5.2", - "contentHash": "qnsKVHbrpLGGxbPvbvQ4UmnUeWvpvhsXLOG8mS9hwX7KbyruZwB4/wKNuSw4L7fLKLJ+Y1xaqCFkZSzEAJq0CA==", + "resolved": "10.0.0", + "contentHash": "H8F7V1zRHkWLP5AW9lCxZypanXlFRT8n7P9Ou8cxz189Yg8TEw5FwTqQCaXjVPRjfE8621lhblpQrghbGJgDZw==", "dependencies": { "EmptyFiles": "2.8.0", "System.Management": "5.0.0" @@ -217,19 +217,14 @@ }, "Microsoft.CodeCoverage": { "type": "Transitive", - "resolved": "17.2.0", - "contentHash": "MsKhJmwIfHxNDbTIlgQy29UpWSWPpbZOQPhQ7xalRy+ABnl8/neFHZGzSP3XlpW2dKAXHTFrtIcKzW/kopY2Bg==" + "resolved": "17.3.1", + "contentHash": "WqB7Ik4v8ku0Y9HZShqTStZdq8R1lyhsZr7IMp8zV/OcL5sHVYvlMnardQR+SDQc3dmbniCIl9mYxYM+V7x8MA==" }, "Microsoft.CSharp": { "type": "Transitive", "resolved": "4.7.0", "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" }, - "Microsoft.Extensions.DependencyInjection.Abstractions": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "ORj7Zh81gC69TyvmcUm9tSzytcy8AVousi+IVRAI8nLieQjOFryRusSFh7+aLk16FN9pQNqJAiMd7BTKINK0kA==" - }, "Microsoft.NETCore.Platforms": { "type": "Transitive", "resolved": "5.0.0", @@ -247,8 +242,8 @@ }, "Microsoft.TestPlatform.ObjectModel": { "type": "Transitive", - "resolved": "17.2.0", - "contentHash": "7j1KYDHLhU98XnCEbECMncXLydI9fNiFLcFsiBsP3lV6EkHOaj5kTPAWHYkKnPGRC9TbZUboSQq8rWI4dTQsxg==", + "resolved": "17.3.1", + "contentHash": "n1WSFCMiFt6KmD5JzV+Wye5Ntomez3YP2+d15bu5PS5Z1U0g+V7VBLdJIaJRnahz5BsXJDTnLYNVOUdntwjx6Q==", "dependencies": { "NuGet.Frameworks": "5.11.0", "System.Reflection.Metadata": "1.6.0" @@ -256,10 +251,10 @@ }, "Microsoft.TestPlatform.TestHost": { "type": "Transitive", - "resolved": "17.2.0", - "contentHash": "bI67J+hers241h7eD2eecS02p9CbKcQDIeoRvO4FgMlTWg2ZTzc0D3uWLYr5U+K5x9O1pNmyMoMDbYIeWY/TWw==", + "resolved": "17.3.1", + "contentHash": "co/GMz6rGxpzn2aJYTDDim61HvEk+SHBVtbXnu2RSrz20HxkaraEh0kltCsMkmLAX/6Hz5sa6NquLngBlURTow==", "dependencies": { - "Microsoft.TestPlatform.ObjectModel": "17.2.0", + "Microsoft.TestPlatform.ObjectModel": "17.3.1", "Newtonsoft.Json": "9.0.1" } }, @@ -1379,34 +1374,25 @@ "System.Xml.ReaderWriter": "4.3.0" } }, - "TextCopy": { - "type": "Transitive", - "resolved": "4.3.1", - "contentHash": "IpRENnjTZXZk7Hi8q0ze6VEFGny9+IIEe+51f/OVQYYzyWVhY8ZLOpYB9CRQoQpo+5/ALKaION1Bxn5LuRCrCw==", - "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "5.0.0" - } - }, "Verify": { "type": "Transitive", - "resolved": "14.11.4", - "contentHash": "lzumaaycdH7LBIpsRnHh3kFo8wwyfSJbXuc8h3/1qToqxfOO5QCIz/uSZk7u4iWqYGhfqoWnXKyS/V5pja/IhQ==", + "resolved": "17.10.2", + "contentHash": "3eMRGukcJOpwjdYqrBOewONaqOC577+aWgbuW/t2LTpmCP9t07vXuB+13GzUFTCidQdj18u1rT6ShuOg+4Jucw==", "dependencies": { - "DiffEngine": "8.5.2", + "DiffEngine": "10.0.0", "EmptyFiles": "2.8.0", "Newtonsoft.Json": "13.0.1", - "SimpleInfoName": "1.1.1", - "TextCopy": "4.3.1" + "SimpleInfoName": "1.1.1" } }, "xunit": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "XNR3Yz9QTtec16O0aKcO6+baVNpXmOnPUxDkCY97J+8krUYxPvXT1szYYEUdKk4sB8GOI2YbAjRIOm8ZnXRfzQ==", + "resolved": "2.4.2", + "contentHash": "6Mj73Ont3zj2CJuoykVJfE0ZmRwn7C+pTuRP8c4bnaaTFjwNG6tGe0prJ1yIbMe9AHrpDys63ctWacSsFJWK/w==", "dependencies": { - "xunit.analyzers": "0.10.0", - "xunit.assert": "[2.4.1]", - "xunit.core": "[2.4.1]" + "xunit.analyzers": "1.0.0", + "xunit.assert": "2.4.2", + "xunit.core": "[2.4.2]" } }, "xunit.abstractions": { @@ -1416,30 +1402,30 @@ }, "xunit.analyzers": { "type": "Transitive", - "resolved": "0.10.0", - "contentHash": "4/IDFCJfIeg6bix9apmUtIMwvOsiwqdEexeO/R2D4GReIGPLIRODTpId/l4LRSrAJk9lEO3Zx1H0Zx6uohJDNg==" + "resolved": "1.0.0", + "contentHash": "BeO8hEgs/c8Ls2647fPfieMngncvf0D0xYNDfIO59MolxtCtVjFRd6SRc+7tj8VMqkVOuJcnc9eh4ngI2cAmLQ==" }, "xunit.assert": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "O/Oe0BS5RmSsM+LQOb041TzuPo5MdH2Rov+qXGS37X+KFG1Hxz7kopYklM5+1Y+tRGeXrOx5+Xne1RuqLFQoyQ==", + "resolved": "2.4.2", + "contentHash": "pxJISOFjn2XTTi1mcDCkRZrTFb9OtRRCtx2kZFNF51GdReLr1ls2rnyxvAS4JO247K3aNtflvh5Q0346K5BROA==", "dependencies": { "NETStandard.Library": "1.6.1" } }, "xunit.core": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "Zsj5OMU6JasNGERXZy8s72+pcheG6Q15atS5XpZXqAtULuyQiQ6XNnUsp1gyfC6WgqScqMvySiEHmHcOG6Eg0Q==", + "resolved": "2.4.2", + "contentHash": "KB4yGCxNqIVyekhJLXtKSEq6BaXVp/JO3mbGVE1hxypZTLEe7h+sTbAhpA+yZW2dPtXTuiW+C1B2oxxHEkrmOw==", "dependencies": { - "xunit.extensibility.core": "[2.4.1]", - "xunit.extensibility.execution": "[2.4.1]" + "xunit.extensibility.core": "[2.4.2]", + "xunit.extensibility.execution": "[2.4.2]" } }, "xunit.extensibility.core": { "type": "Transitive", - "resolved": "2.4.1", - "contentHash": "yKZKm/8QNZnBnGZFD9SewkllHBiK0DThybQD/G4PiAmQjKtEZyHi6ET70QPU9KtSMJGRYS6Syk7EyR2EVDU4Kg==", + "resolved": "2.4.2", + "contentHash": "W1BoXTIN1C6kpVSMw25huSet25ky6IAQUNovu3zGOGN/jWnbgSoTyCrlIhmXSg0tH5nEf8q7h3OjNHOjyu5PfA==", "dependencies": { "NETStandard.Library": "1.6.1", "xunit.abstractions": "2.0.3" @@ -1448,52 +1434,52 @@ "elastic.clients.elasticsearch": { "type": "Project", "dependencies": { - "Elastic.Transport": "0.3.2" + "Elastic.Transport": "[0.3.2, )" } }, "elastic.clients.elasticsearch.jsonnetserializer": { "type": "Project", "dependencies": { - "Elastic.Clients.Elasticsearch": "8.0.0", - "Newtonsoft.Json": "13.0.1" + "Elastic.Clients.Elasticsearch": "[8.0.0, )", + "Newtonsoft.Json": "[13.0.1, )" } }, "tests.clusterlauncher": { "type": "Project", "dependencies": { - "Tests.Core": "8.0.0" + "Tests.Core": "[8.0.0, )" } }, "tests.configuration": { "type": "Project", "dependencies": { - "Elastic.Elasticsearch.Managed": "0.3.5" + "Elastic.Elasticsearch.Managed": "[0.3.5, )" } }, "tests.core": { "type": "Project", "dependencies": { - "DiffPlex": "1.4.1", - "Elastic.Clients.Elasticsearch.JsonNetSerializer": "8.0.0", - "Elastic.Elasticsearch.Xunit": "0.3.5", - "FluentAssertions": "5.10.3", - "JunitXml.TestLogger": "3.0.110", - "Microsoft.Bcl.HashCode": "1.1.1", - "Microsoft.NET.Test.Sdk": "17.2.0", - "Nullean.VsTest.Pretty.TestLogger": "0.3.0", - "Proc": "0.6.1", - "Tests.Domain": "8.0.0", - "xunit": "2.4.1" + "DiffPlex": "[1.4.1, )", + "Elastic.Clients.Elasticsearch.JsonNetSerializer": "[8.0.0, )", + "Elastic.Elasticsearch.Xunit": "[0.3.5, )", + "FluentAssertions": "[5.10.3, )", + "JunitXml.TestLogger": "[3.0.110, )", + "Microsoft.Bcl.HashCode": "[1.1.1, )", + "Microsoft.NET.Test.Sdk": "[17.2.0, )", + "Nullean.VsTest.Pretty.TestLogger": "[0.3.0, )", + "Proc": "[0.6.1, )", + "Tests.Domain": "[8.0.0, )", + "xunit": "[2.4.2, )" } }, "tests.domain": { "type": "Project", "dependencies": { - "Bogus": "22.1.2", - "Elastic.Clients.Elasticsearch": "8.0.0", - "Elastic.Elasticsearch.Managed": "0.3.5", - "Newtonsoft.Json": "13.0.1", - "Tests.Configuration": "8.0.0" + "Bogus": "[22.1.2, )", + "Elastic.Clients.Elasticsearch": "[8.0.0, )", + "Elastic.Elasticsearch.Managed": "[0.3.5, )", + "Newtonsoft.Json": "[13.0.1, )", + "Tests.Configuration": "[8.0.0, )" } } }