diff --git a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionaryConverter.cs b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionaryConverter.cs index 53861cab923..8a5aeda2061 100644 --- a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionaryConverter.cs +++ b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionaryConverter.cs @@ -407,8 +407,14 @@ public static void ReadAggregate(ref Utf8JsonReader reader, JsonSerializerOption break; } - case "cumulative_sum": - throw new Exception("The aggregate in response is not yet supported."); + // Used by: + // - cumulative sum aggregation + case "simple_value": + { + var agg = JsonSerializer.Deserialize(ref reader, options); + dictionary.Add(nameParts[1], agg); + break; + } case "derivative": { diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs index d71f2eef54c..2b4d4589a32 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs @@ -41,11 +41,6 @@ public sealed class FieldCapsRequestParameters : RequestParameters /// public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } - /// - /// Comma-separated list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported. - /// - public Elastic.Clients.Elasticsearch.Fields? Fields { get => Q("fields"); set => Q("fields", value); } - /// /// If `true`, missing or closed indices are not included in the response. /// @@ -98,12 +93,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } - /// - /// Comma-separated list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported. - /// - [JsonIgnore] - public Elastic.Clients.Elasticsearch.Fields? Fields { get => Q("fields"); set => Q("fields", value); } - /// /// If `true`, missing or closed indices are not included in the response. /// @@ -128,6 +117,12 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r [JsonIgnore] public ICollection? Types { get => Q?>("types"); set => Q("types", value); } + /// + /// List of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported. + /// + [JsonInclude, JsonPropertyName("fields")] + public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } + /// /// Allows to filter indices if the provided query rewrites to match_none on every shard. /// @@ -160,7 +155,6 @@ public FieldCapsRequestDescriptor() public FieldCapsRequestDescriptor AllowNoIndices(bool? allowNoIndices = true) => Qs("allow_no_indices", allowNoIndices); public FieldCapsRequestDescriptor ExpandWildcards(ICollection? expandWildcards) => Qs("expand_wildcards", expandWildcards); - public FieldCapsRequestDescriptor Fields(Elastic.Clients.Elasticsearch.Fields? fields) => Qs("fields", fields); public FieldCapsRequestDescriptor Filters(string? filters) => Qs("filters", filters); public FieldCapsRequestDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Qs("ignore_unavailable", ignoreUnavailable); public FieldCapsRequestDescriptor IncludeUnmapped(bool? includeUnmapped = true) => Qs("include_unmapped", includeUnmapped); @@ -175,6 +169,7 @@ public FieldCapsRequestDescriptor Indices(Elastic.Clients.Elasticsear private Elastic.Clients.Elasticsearch.QueryDsl.Query? IndexFilterValue { get; set; } private QueryDsl.QueryDescriptor IndexFilterDescriptor { get; set; } private Action> IndexFilterDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Fields? FieldsValue { get; set; } private IDictionary? RuntimeMappingsValue { get; set; } /// @@ -204,6 +199,15 @@ public FieldCapsRequestDescriptor IndexFilter(Action + /// List of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported. + /// + public FieldCapsRequestDescriptor Fields(Elastic.Clients.Elasticsearch.Fields? fields) + { + FieldsValue = fields; + return Self; + } + /// /// Defines ad-hoc runtime fields in the request similar to the way it is done in search requests.
These fields exist only as part of the query and take precedence over fields defined with the same name in the index mappings.
///
@@ -232,6 +236,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, IndexFilterValue, options); } + if (FieldsValue is not null) + { + writer.WritePropertyName("fields"); + JsonSerializer.Serialize(writer, FieldsValue, options); + } + if (RuntimeMappingsValue is not null) { writer.WritePropertyName("runtime_mappings"); @@ -261,7 +271,6 @@ public FieldCapsRequestDescriptor() public FieldCapsRequestDescriptor AllowNoIndices(bool? allowNoIndices = true) => Qs("allow_no_indices", allowNoIndices); public FieldCapsRequestDescriptor ExpandWildcards(ICollection? expandWildcards) => Qs("expand_wildcards", expandWildcards); - public FieldCapsRequestDescriptor Fields(Elastic.Clients.Elasticsearch.Fields? fields) => Qs("fields", fields); public FieldCapsRequestDescriptor Filters(string? filters) => Qs("filters", filters); public FieldCapsRequestDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Qs("ignore_unavailable", ignoreUnavailable); public FieldCapsRequestDescriptor IncludeUnmapped(bool? includeUnmapped = true) => Qs("include_unmapped", includeUnmapped); @@ -276,6 +285,7 @@ public FieldCapsRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? private Elastic.Clients.Elasticsearch.QueryDsl.Query? IndexFilterValue { get; set; } private QueryDsl.QueryDescriptor IndexFilterDescriptor { get; set; } private Action IndexFilterDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Fields? FieldsValue { get; set; } private IDictionary? RuntimeMappingsValue { get; set; } /// @@ -305,6 +315,15 @@ public FieldCapsRequestDescriptor IndexFilter(Action c return Self; } + /// + /// List of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported. + /// + public FieldCapsRequestDescriptor Fields(Elastic.Clients.Elasticsearch.Fields? fields) + { + FieldsValue = fields; + return Self; + } + /// /// Defines ad-hoc runtime fields in the request similar to the way it is done in search requests.
These fields exist only as part of the query and take precedence over fields defined with the same name in the index mappings.
///
@@ -333,6 +352,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, IndexFilterValue, options); } + if (FieldsValue is not null) + { + writer.WritePropertyName("fields"); + JsonSerializer.Serialize(writer, FieldsValue, options); + } + if (RuntimeMappingsValue is not null) { writer.WritePropertyName("runtime_mappings"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs index 3d4b2e6cecf..85f6ca5479c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs @@ -245,7 +245,7 @@ public override SearchRequest Read(ref Utf8JsonReader reader, Type typeToConvert if (property == "knn") { - variant.Knn = JsonSerializer.Deserialize(ref reader, options); + variant.Knn = JsonSerializer.Deserialize?>(ref reader, options); continue; } @@ -824,8 +824,8 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// /// Defines the approximate kNN search to run. /// - [JsonInclude, JsonPropertyName("knn")] - public Elastic.Clients.Elasticsearch.KnnQuery? Knn { get; set; } + [JsonInclude, JsonPropertyName("knn"), SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.KnnQuery))] + public ICollection? Knn { get; set; } /// /// Minimum _score for matching documents. Documents with a lower _score are
not included in the search results.
@@ -1016,9 +1016,10 @@ public SearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch. private Elastic.Clients.Elasticsearch.Core.Search.Highlight? HighlightValue { get; set; } private Core.Search.HighlightDescriptor HighlightDescriptor { get; set; } private Action> HighlightDescriptorAction { get; set; } - private Elastic.Clients.Elasticsearch.KnnQuery? KnnValue { get; set; } + private ICollection? KnnValue { get; set; } private KnnQueryDescriptor KnnDescriptor { get; set; } private Action> KnnDescriptorAction { get; set; } + private Action>[] KnnDescriptorActions { get; set; } private Elastic.Clients.Elasticsearch.QueryDsl.Query? PostFilterValue { get; set; } private QueryDsl.QueryDescriptor PostFilterDescriptor { get; set; } private Action> PostFilterDescriptorAction { get; set; } @@ -1215,10 +1216,11 @@ public SearchRequestDescriptor Highlight(Action /// Defines the approximate kNN search to run. ///
- public SearchRequestDescriptor Knn(Elastic.Clients.Elasticsearch.KnnQuery? knn) + public SearchRequestDescriptor Knn(ICollection? knn) { KnnDescriptor = null; KnnDescriptorAction = null; + KnnDescriptorActions = null; KnnValue = knn; return Self; } @@ -1227,6 +1229,7 @@ public SearchRequestDescriptor Knn(KnnQueryDescriptor desc { KnnValue = null; KnnDescriptorAction = null; + KnnDescriptorActions = null; KnnDescriptor = descriptor; return Self; } @@ -1235,10 +1238,20 @@ public SearchRequestDescriptor Knn(Action Knn(params Action>[] configure) + { + KnnValue = null; + KnnDescriptor = null; + KnnDescriptorAction = null; + KnnDescriptorActions = configure; + return Self; + } + public SearchRequestDescriptor PostFilter(Elastic.Clients.Elasticsearch.QueryDsl.Query? postFilter) { PostFilterDescriptor = null; @@ -1725,10 +1738,23 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WritePropertyName("knn"); JsonSerializer.Serialize(writer, new KnnQueryDescriptor(KnnDescriptorAction), options); } + else if (KnnDescriptorActions is not null) + { + writer.WritePropertyName("knn"); + if (KnnDescriptorActions.Length > 1) + writer.WriteStartArray(); + foreach (var action in KnnDescriptorActions) + { + JsonSerializer.Serialize(writer, new KnnQueryDescriptor(action), options); + } + + if (KnnDescriptorActions.Length > 1) + writer.WriteEndArray(); + } else if (KnnValue is not null) { writer.WritePropertyName("knn"); - JsonSerializer.Serialize(writer, KnnValue, options); + SingleOrManySerializationHelper.Serialize(KnnValue, writer, options); } if (PostFilterDescriptor is not null) @@ -2061,9 +2087,10 @@ public SearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? in private Elastic.Clients.Elasticsearch.Core.Search.Highlight? HighlightValue { get; set; } private Core.Search.HighlightDescriptor HighlightDescriptor { get; set; } private Action HighlightDescriptorAction { get; set; } - private Elastic.Clients.Elasticsearch.KnnQuery? KnnValue { get; set; } + private ICollection? KnnValue { get; set; } private KnnQueryDescriptor KnnDescriptor { get; set; } private Action KnnDescriptorAction { get; set; } + private Action[] KnnDescriptorActions { get; set; } private Elastic.Clients.Elasticsearch.QueryDsl.Query? PostFilterValue { get; set; } private QueryDsl.QueryDescriptor PostFilterDescriptor { get; set; } private Action PostFilterDescriptorAction { get; set; } @@ -2260,10 +2287,11 @@ public SearchRequestDescriptor Highlight(Action /// /// Defines the approximate kNN search to run. /// - public SearchRequestDescriptor Knn(Elastic.Clients.Elasticsearch.KnnQuery? knn) + public SearchRequestDescriptor Knn(ICollection? knn) { KnnDescriptor = null; KnnDescriptorAction = null; + KnnDescriptorActions = null; KnnValue = knn; return Self; } @@ -2272,6 +2300,7 @@ public SearchRequestDescriptor Knn(KnnQueryDescriptor descriptor) { KnnValue = null; KnnDescriptorAction = null; + KnnDescriptorActions = null; KnnDescriptor = descriptor; return Self; } @@ -2280,10 +2309,20 @@ public SearchRequestDescriptor Knn(Action configure) { KnnValue = null; KnnDescriptor = null; + KnnDescriptorActions = null; KnnDescriptorAction = configure; return Self; } + public SearchRequestDescriptor Knn(params Action[] configure) + { + KnnValue = null; + KnnDescriptor = null; + KnnDescriptorAction = null; + KnnDescriptorActions = configure; + return Self; + } + public SearchRequestDescriptor PostFilter(Elastic.Clients.Elasticsearch.QueryDsl.Query? postFilter) { PostFilterDescriptor = null; @@ -2770,10 +2809,23 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WritePropertyName("knn"); JsonSerializer.Serialize(writer, new KnnQueryDescriptor(KnnDescriptorAction), options); } + else if (KnnDescriptorActions is not null) + { + writer.WritePropertyName("knn"); + if (KnnDescriptorActions.Length > 1) + writer.WriteStartArray(); + foreach (var action in KnnDescriptorActions) + { + JsonSerializer.Serialize(writer, new KnnQueryDescriptor(action), options); + } + + if (KnnDescriptorActions.Length > 1) + writer.WriteEndArray(); + } else if (KnnValue is not null) { writer.WritePropertyName("knn"); - JsonSerializer.Serialize(writer, KnnValue, options); + SingleOrManySerializationHelper.Serialize(KnnValue, writer, options); } if (PostFilterDescriptor is not null) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryRequest.g.cs index cee61880a6e..0f093d0c634 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryRequest.g.cs @@ -49,6 +49,10 @@ public sealed partial class QueryRequest : PlainRequest ///
[JsonInclude, JsonPropertyName("catalog")] public string? Catalog { get; set; } + + /// + /// If true, the results in a columnar fashion: one row represents all the values of a certain column from the current page of results. + /// [JsonInclude, JsonPropertyName("columnar")] public bool? Columnar { get; set; } [JsonInclude, JsonPropertyName("cursor")] @@ -205,6 +209,9 @@ public QueryRequestDescriptor Catalog(string? catalog) return Self; } + /// + /// If true, the results in a columnar fashion: one row represents all the values of a certain column from the current page of results. + /// public QueryRequestDescriptor Columnar(bool? columnar = true) { ColumnarValue = columnar; @@ -510,6 +517,9 @@ public QueryRequestDescriptor Catalog(string? catalog) return Self; } + /// + /// If true, the results in a columnar fashion: one row represents all the values of a certain column from the current page of results. + /// public QueryRequestDescriptor Columnar(bool? columnar = true) { ColumnarValue = columnar; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.AsyncSearch.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.AsyncSearch.g.cs index ce7642dcb21..fa8d5e71242 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.AsyncSearch.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.AsyncSearch.g.cs @@ -38,7 +38,7 @@ internal AsyncSearchNamespacedClient(ElasticsearchClient client) : base(client) /// /// Retrieves the status of a previously submitted async search request given its ID. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual AsyncSearchStatusResponse Status(AsyncSearchStatusRequest request) { @@ -48,7 +48,7 @@ public virtual AsyncSearchStatusResponse Status(AsyncSearchStatusRequest request /// /// Retrieves the status of a previously submitted async search request given its ID. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual Task StatusAsync(AsyncSearchStatusRequest request, CancellationToken cancellationToken = default) { @@ -104,7 +104,7 @@ public virtual Task StatusAsync(Elastic.Cl /// /// Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual DeleteAsyncSearchResponse Delete(DeleteAsyncSearchRequest request) { @@ -114,7 +114,7 @@ public virtual DeleteAsyncSearchResponse Delete(DeleteAsyncSearchRequest request /// /// Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual Task DeleteAsync(DeleteAsyncSearchRequest request, CancellationToken cancellationToken = default) { @@ -170,7 +170,7 @@ public virtual Task DeleteAsync(Elastic.Cl /// /// Retrieves the results of a previously submitted async search request given its ID. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual GetAsyncSearchResponse Get(GetAsyncSearchRequest request) { @@ -180,7 +180,7 @@ public virtual GetAsyncSearchResponse Get(GetAsyncSearchRe /// /// Retrieves the results of a previously submitted async search request given its ID. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual Task> GetAsync(GetAsyncSearchRequest request, CancellationToken cancellationToken = default) { @@ -220,7 +220,7 @@ public virtual Task> GetAsync(Elast /// /// Executes a search request asynchronously. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual SubmitAsyncSearchResponse Submit(SubmitAsyncSearchRequest request) { @@ -230,7 +230,7 @@ public virtual SubmitAsyncSearchResponse Submit(SubmitAsyn /// /// Executes a search request asynchronously. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual Task> SubmitAsync(SubmitAsyncSearchRequest request, CancellationToken cancellationToken = default) { diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Cluster.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Cluster.g.cs index 91e4090ffc4..0d37b79f8a8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Cluster.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Cluster.g.cs @@ -38,7 +38,7 @@ internal ClusterNamespacedClient(ElasticsearchClient client) : base(client) /// /// Returns basic information about the health of the cluster. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual HealthResponse Health(HealthRequest request) { @@ -48,7 +48,7 @@ public virtual HealthResponse Health(HealthRequest request) /// /// Returns basic information about the health of the cluster. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual Task HealthAsync(HealthRequest request, CancellationToken cancellationToken = default) { diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs index fefe4b381c5..689272d1b64 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs @@ -45,7 +45,7 @@ private partial void SetupNamespaces() /// /// Allows to perform multiple index/update/delete operations in a single request. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual BulkResponse Bulk(BulkRequest request) { @@ -55,7 +55,7 @@ public virtual BulkResponse Bulk(BulkRequest request) /// /// Allows to perform multiple index/update/delete operations in a single request. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual Task BulkAsync(BulkRequest request, CancellationToken cancellationToken = default) { @@ -111,7 +111,7 @@ public virtual Task BulkAsync(Action /// Explicitly clears the search context for a scroll. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual ClearScrollResponse ClearScroll(ClearScrollRequest request) { @@ -121,7 +121,7 @@ public virtual ClearScrollResponse ClearScroll(ClearScrollRequest request) /// /// Explicitly clears the search context for a scroll. - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual Task ClearScrollAsync(ClearScrollRequest request, CancellationToken cancellationToken = default) { @@ -161,7 +161,7 @@ public virtual Task ClearScrollAsync(Action /// Close a point in time - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual ClosePointInTimeResponse ClosePointInTime(ClosePointInTimeRequest request) { @@ -171,7 +171,7 @@ public virtual ClosePointInTimeResponse ClosePointInTime(ClosePointInTimeRequest /// /// Close a point in time - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual Task ClosePointInTimeAsync(ClosePointInTimeRequest request, CancellationToken cancellationToken = default) { @@ -1581,7 +1581,7 @@ public virtual Task> MultiSearchTemplateA /// /// Open a point in time that can be used in subsequent searches - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual OpenPointInTimeResponse OpenPointInTime(OpenPointInTimeRequest request) { @@ -1591,7 +1591,7 @@ public virtual OpenPointInTimeResponse OpenPointInTime(OpenPointInTimeRequest re /// /// Open a point in time that can be used in subsequent searches - /// Learn more about this API in the Elasticsearch documentation. + /// Learn more about this API in the Elasticsearch documentation. /// public virtual Task OpenPointInTimeAsync(OpenPointInTimeRequest request, CancellationToken cancellationToken = default) { diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketsPath.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketsPath.g.cs new file mode 100644 index 00000000000..bba2ad5a659 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketsPath.g.cs @@ -0,0 +1,123 @@ +// 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. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Core; +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using Elastic.Transport; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.Aggregations; + +/// +/// Buckets path can be expressed in different ways, and an aggregation may accept some or all of these
forms depending on its type. Please refer to each aggregation's documentation to know what buckets
path forms they accept.
+///
+[JsonConverter(typeof(BucketsPathConverter))] +public sealed partial class BucketsPath : IComplexUnion +{ + public enum Kind + { + Single, + Array, + Dictionary + } + + private readonly Kind _kind; + private readonly object _value; + + Kind IComplexUnion.ValueKind => _kind; + + object IComplexUnion.Value => _value; + + private BucketsPath(Kind kind, object value) + { + _kind = kind; + _value = value; + } + + public static BucketsPath Single(string single) => new(Kind.Single, single); + + public bool IsSingle => _kind == Kind.Single; + + public bool TryGetSingle([NotNullWhen(true)] out string? single) + { + single = null; + if (_kind == Kind.Single) + { + single = (string)_value; + return true; + } + + return false; + } + + public static implicit operator BucketsPath(string single) => BucketsPath.Single(single); + + public static BucketsPath Array(string[] array) => new(Kind.Array, array); + + public bool IsArray => _kind == Kind.Array; + + public bool TryGetArray([NotNullWhen(true)] out string[]? array) + { + array = null; + if (_kind == Kind.Array) + { + array = (string[])_value; + return true; + } + + return false; + } + + public static implicit operator BucketsPath(string[] array) => BucketsPath.Array(array); + + public static BucketsPath Dictionary(Dictionary dictionary) => new(Kind.Dictionary, dictionary); + + public bool IsDictionary => _kind == Kind.Dictionary; + + public bool TryGetDictionary([NotNullWhen(true)] out Dictionary? dictionary) + { + dictionary = null; + if (_kind == Kind.Dictionary) + { + dictionary = (Dictionary)_value; + return true; + } + + return false; + } + + public static implicit operator BucketsPath(Dictionary dictionary) => BucketsPath.Dictionary(dictionary); +} + +internal sealed class BucketsPathConverter : MultiItemUnionConverter +{ + public BucketsPathConverter() + { + _arrayType = typeof(string[]); + _types = new Dictionary { { BucketsPath.Kind.Single, typeof(string) }, { BucketsPath.Kind.Array, typeof(string[]) }, { BucketsPath.Kind.Dictionary, typeof(Dictionary) } }; + _factories = new Dictionary> { { typeof(string), o => BucketsPath.Single((string)o) }, { typeof(string[]), o => BucketsPath.Array((string[])o) }, { typeof(Dictionary), o => BucketsPath.Dictionary((Dictionary)o) } }; + _uniquePropertyToType = new Dictionary { }; + } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregation.g.cs index 5945599f054..1bdbd6f123e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregation.g.cs @@ -42,6 +42,18 @@ public override CumulativeCardinalityAggregation Read(ref Utf8JsonReader reader, { if (reader.TokenType == JsonTokenType.PropertyName) { + if (reader.ValueTextEquals("buckets_path")) + { + reader.Read(); + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.BucketsPath = value; + } + + continue; + } + if (reader.ValueTextEquals("format")) { reader.Read(); @@ -93,6 +105,12 @@ public override void Write(Utf8JsonWriter writer, CumulativeCardinalityAggregati writer.WriteStartObject(); writer.WritePropertyName("cumulative_cardinality"); writer.WriteStartObject(); + if (value.BucketsPath is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, value.BucketsPath, options); + } + if (!string.IsNullOrEmpty(value.Format)) { writer.WritePropertyName("format"); @@ -125,6 +143,7 @@ internal CumulativeCardinalityAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPath { get; set; } public string? Format { get; set; } public Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicy { get; set; } public IDictionary? Meta { get; set; } @@ -139,10 +158,17 @@ public CumulativeCardinalityAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPathValue { get; set; } private string? FormatValue { get; set; } private Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicyValue { get; set; } private IDictionary? MetaValue { get; set; } + public CumulativeCardinalityAggregationDescriptor BucketsPath(Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? bucketsPath) + { + BucketsPathValue = bucketsPath; + return Self; + } + public CumulativeCardinalityAggregationDescriptor Format(string? format) { FormatValue = format; @@ -166,6 +192,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteStartObject(); writer.WritePropertyName("cumulative_cardinality"); writer.WriteStartObject(); + if (BucketsPathValue is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, BucketsPathValue, options); + } + if (!string.IsNullOrEmpty(FormatValue)) { writer.WritePropertyName("format"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeSumAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeSumAggregation.g.cs index 0b13493acf1..99b8642e243 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeSumAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeSumAggregation.g.cs @@ -42,6 +42,18 @@ public override CumulativeSumAggregation Read(ref Utf8JsonReader reader, Type ty { if (reader.TokenType == JsonTokenType.PropertyName) { + if (reader.ValueTextEquals("buckets_path")) + { + reader.Read(); + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.BucketsPath = value; + } + + continue; + } + if (reader.ValueTextEquals("format")) { reader.Read(); @@ -93,6 +105,12 @@ public override void Write(Utf8JsonWriter writer, CumulativeSumAggregation value writer.WriteStartObject(); writer.WritePropertyName("cumulative_sum"); writer.WriteStartObject(); + if (value.BucketsPath is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, value.BucketsPath, options); + } + if (!string.IsNullOrEmpty(value.Format)) { writer.WritePropertyName("format"); @@ -125,6 +143,7 @@ internal CumulativeSumAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPath { get; set; } public string? Format { get; set; } public Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicy { get; set; } public IDictionary? Meta { get; set; } @@ -139,10 +158,17 @@ public CumulativeSumAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPathValue { get; set; } private string? FormatValue { get; set; } private Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicyValue { get; set; } private IDictionary? MetaValue { get; set; } + public CumulativeSumAggregationDescriptor BucketsPath(Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? bucketsPath) + { + BucketsPathValue = bucketsPath; + return Self; + } + public CumulativeSumAggregationDescriptor Format(string? format) { FormatValue = format; @@ -166,6 +192,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteStartObject(); writer.WritePropertyName("cumulative_sum"); writer.WriteStartObject(); + if (BucketsPathValue is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, BucketsPathValue, options); + } + if (!string.IsNullOrEmpty(FormatValue)) { writer.WritePropertyName("format"); @@ -187,4 +219,4 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteEndObject(); } -} \ No newline at end of file +} diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregation.g.cs index b2e6eecd6a8..116e2c8b1f6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregation.g.cs @@ -42,6 +42,18 @@ public override DerivativeAggregation Read(ref Utf8JsonReader reader, Type typeT { if (reader.TokenType == JsonTokenType.PropertyName) { + if (reader.ValueTextEquals("buckets_path")) + { + reader.Read(); + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.BucketsPath = value; + } + + continue; + } + if (reader.ValueTextEquals("format")) { reader.Read(); @@ -93,6 +105,12 @@ public override void Write(Utf8JsonWriter writer, DerivativeAggregation value, J writer.WriteStartObject(); writer.WritePropertyName("derivative"); writer.WriteStartObject(); + if (value.BucketsPath is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, value.BucketsPath, options); + } + if (!string.IsNullOrEmpty(value.Format)) { writer.WritePropertyName("format"); @@ -125,6 +143,7 @@ internal DerivativeAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPath { get; set; } public string? Format { get; set; } public Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicy { get; set; } public IDictionary? Meta { get; set; } @@ -139,10 +158,17 @@ public DerivativeAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPathValue { get; set; } private string? FormatValue { get; set; } private Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicyValue { get; set; } private IDictionary? MetaValue { get; set; } + public DerivativeAggregationDescriptor BucketsPath(Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? bucketsPath) + { + BucketsPathValue = bucketsPath; + return Self; + } + public DerivativeAggregationDescriptor Format(string? format) { FormatValue = format; @@ -166,6 +192,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteStartObject(); writer.WritePropertyName("derivative"); writer.WriteStartObject(); + if (BucketsPathValue is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, BucketsPathValue, options); + } + if (!string.IsNullOrEmpty(FormatValue)) { writer.WritePropertyName("format"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregation.g.cs index 0508e9a1b15..aad64d6ab21 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregation.g.cs @@ -42,6 +42,18 @@ public override ExtendedStatsBucketAggregation Read(ref Utf8JsonReader reader, T { if (reader.TokenType == JsonTokenType.PropertyName) { + if (reader.ValueTextEquals("buckets_path")) + { + reader.Read(); + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.BucketsPath = value; + } + + continue; + } + if (reader.ValueTextEquals("format")) { reader.Read(); @@ -105,6 +117,12 @@ public override void Write(Utf8JsonWriter writer, ExtendedStatsBucketAggregation writer.WriteStartObject(); writer.WritePropertyName("extended_stats_bucket"); writer.WriteStartObject(); + if (value.BucketsPath is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, value.BucketsPath, options); + } + if (!string.IsNullOrEmpty(value.Format)) { writer.WritePropertyName("format"); @@ -143,6 +161,7 @@ internal ExtendedStatsBucketAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPath { get; set; } public string? Format { get; set; } public Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicy { get; set; } public IDictionary? Meta { get; set; } @@ -158,11 +177,18 @@ public ExtendedStatsBucketAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPathValue { get; set; } private string? FormatValue { get; set; } private Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicyValue { get; set; } private IDictionary? MetaValue { get; set; } private double? SigmaValue { get; set; } + public ExtendedStatsBucketAggregationDescriptor BucketsPath(Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? bucketsPath) + { + BucketsPathValue = bucketsPath; + return Self; + } + public ExtendedStatsBucketAggregationDescriptor Format(string? format) { FormatValue = format; @@ -192,6 +218,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteStartObject(); writer.WritePropertyName("extended_stats_bucket"); writer.WriteStartObject(); + if (BucketsPathValue is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, BucketsPathValue, options); + } + if (!string.IsNullOrEmpty(FormatValue)) { writer.WritePropertyName("format"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregation.g.cs index adeac39b62b..f5a32a00153 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregation.g.cs @@ -42,6 +42,18 @@ public override InferenceAggregation Read(ref Utf8JsonReader reader, Type typeTo { if (reader.TokenType == JsonTokenType.PropertyName) { + if (reader.ValueTextEquals("buckets_path")) + { + reader.Read(); + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.BucketsPath = value; + } + + continue; + } + if (reader.ValueTextEquals("format")) { reader.Read(); @@ -117,6 +129,12 @@ public override void Write(Utf8JsonWriter writer, InferenceAggregation value, Js writer.WriteStartObject(); writer.WritePropertyName("inference"); writer.WriteStartObject(); + if (value.BucketsPath is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, value.BucketsPath, options); + } + if (!string.IsNullOrEmpty(value.Format)) { writer.WritePropertyName("format"); @@ -157,6 +175,7 @@ internal InferenceAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPath { get; set; } public string? Format { get; set; } public Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicy { get; set; } public Elastic.Clients.Elasticsearch.Aggregations.InferenceConfig? InferenceConfig { get; set; } @@ -176,6 +195,7 @@ public InferenceAggregationDescriptor() : base() private Elastic.Clients.Elasticsearch.Aggregations.InferenceConfig? InferenceConfigValue { get; set; } private InferenceConfigDescriptor InferenceConfigDescriptor { get; set; } private Action> InferenceConfigDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPathValue { get; set; } private string? FormatValue { get; set; } private Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicyValue { get; set; } private IDictionary? MetaValue { get; set; } @@ -205,6 +225,12 @@ public InferenceAggregationDescriptor InferenceConfig(Action BucketsPath(Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? bucketsPath) + { + BucketsPathValue = bucketsPath; + return Self; + } + public InferenceAggregationDescriptor Format(string? format) { FormatValue = format; @@ -250,6 +276,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, InferenceConfigValue, options); } + if (BucketsPathValue is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, BucketsPathValue, options); + } + if (!string.IsNullOrEmpty(FormatValue)) { writer.WritePropertyName("format"); @@ -286,6 +318,7 @@ public InferenceAggregationDescriptor() : base() private Elastic.Clients.Elasticsearch.Aggregations.InferenceConfig? InferenceConfigValue { get; set; } private InferenceConfigDescriptor InferenceConfigDescriptor { get; set; } private Action InferenceConfigDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPathValue { get; set; } private string? FormatValue { get; set; } private Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicyValue { get; set; } private IDictionary? MetaValue { get; set; } @@ -315,6 +348,12 @@ public InferenceAggregationDescriptor InferenceConfig(Action Fields { get; init; } + public IReadOnlyCollection? Fields { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregation.g.cs index bfbe5062729..59e5ea9444d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregation.g.cs @@ -42,6 +42,18 @@ public override PercentilesBucketAggregation Read(ref Utf8JsonReader reader, Typ { if (reader.TokenType == JsonTokenType.PropertyName) { + if (reader.ValueTextEquals("buckets_path")) + { + reader.Read(); + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.BucketsPath = value; + } + + continue; + } + if (reader.ValueTextEquals("format")) { reader.Read(); @@ -105,6 +117,12 @@ public override void Write(Utf8JsonWriter writer, PercentilesBucketAggregation v writer.WriteStartObject(); writer.WritePropertyName("percentiles_bucket"); writer.WriteStartObject(); + if (value.BucketsPath is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, value.BucketsPath, options); + } + if (!string.IsNullOrEmpty(value.Format)) { writer.WritePropertyName("format"); @@ -143,6 +161,7 @@ internal PercentilesBucketAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPath { get; set; } public string? Format { get; set; } public Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicy { get; set; } public IDictionary? Meta { get; set; } @@ -158,11 +177,18 @@ public PercentilesBucketAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPathValue { get; set; } private string? FormatValue { get; set; } private Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicyValue { get; set; } private IDictionary? MetaValue { get; set; } private ICollection? PercentsValue { get; set; } + public PercentilesBucketAggregationDescriptor BucketsPath(Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? bucketsPath) + { + BucketsPathValue = bucketsPath; + return Self; + } + public PercentilesBucketAggregationDescriptor Format(string? format) { FormatValue = format; @@ -192,6 +218,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteStartObject(); writer.WritePropertyName("percentiles_bucket"); writer.WriteStartObject(); + if (BucketsPathValue is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, BucketsPathValue, options); + } + if (!string.IsNullOrEmpty(FormatValue)) { writer.WritePropertyName("format"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregation.g.cs index 70c71949dd5..04d7572d564 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregation.g.cs @@ -42,6 +42,18 @@ public override StatsBucketAggregation Read(ref Utf8JsonReader reader, Type type { if (reader.TokenType == JsonTokenType.PropertyName) { + if (reader.ValueTextEquals("buckets_path")) + { + reader.Read(); + var value = JsonSerializer.Deserialize(ref reader, options); + if (value is not null) + { + agg.BucketsPath = value; + } + + continue; + } + if (reader.ValueTextEquals("format")) { reader.Read(); @@ -93,6 +105,12 @@ public override void Write(Utf8JsonWriter writer, StatsBucketAggregation value, writer.WriteStartObject(); writer.WritePropertyName("stats_bucket"); writer.WriteStartObject(); + if (value.BucketsPath is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, value.BucketsPath, options); + } + if (!string.IsNullOrEmpty(value.Format)) { writer.WritePropertyName("format"); @@ -125,6 +143,7 @@ internal StatsBucketAggregation() { } + public Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPath { get; set; } public string? Format { get; set; } public Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicy { get; set; } public IDictionary? Meta { get; set; } @@ -139,10 +158,17 @@ public StatsBucketAggregationDescriptor() : base() { } + private Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? BucketsPathValue { get; set; } private string? FormatValue { get; set; } private Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicyValue { get; set; } private IDictionary? MetaValue { get; set; } + public StatsBucketAggregationDescriptor BucketsPath(Elastic.Clients.Elasticsearch.Aggregations.BucketsPath? bucketsPath) + { + BucketsPathValue = bucketsPath; + return Self; + } + public StatsBucketAggregationDescriptor Format(string? format) { FormatValue = format; @@ -166,6 +192,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteStartObject(); writer.WritePropertyName("stats_bucket"); writer.WriteStartObject(); + if (BucketsPathValue is not null) + { + writer.WritePropertyName("buckets_path"); + JsonSerializer.Serialize(writer, BucketsPathValue, options); + } + if (!string.IsNullOrEmpty(FormatValue)) { writer.WritePropertyName("format"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs index 72b41a7c36d..4d0568d2b37 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs @@ -630,6 +630,8 @@ public override void Write(Utf8JsonWriter writer, OnScriptError value, JsonSeria [JsonConverter(typeof(RuntimeFieldTypeConverter))] public enum RuntimeFieldType { + [EnumMember(Value = "lookup")] + Lookup, [EnumMember(Value = "long")] Long, [EnumMember(Value = "keyword")] @@ -653,6 +655,8 @@ public override RuntimeFieldType Read(ref Utf8JsonReader reader, Type typeToConv var enumString = reader.GetString(); switch (enumString) { + case "lookup": + return RuntimeFieldType.Lookup; case "long": return RuntimeFieldType.Long; case "keyword": @@ -676,6 +680,9 @@ public override void Write(Utf8JsonWriter writer, RuntimeFieldType value, JsonSe { switch (value) { + case RuntimeFieldType.Lookup: + writer.WriteStringValue("lookup"); + return; case RuntimeFieldType.Long: writer.WriteStringValue("long"); return; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoBounds.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoBounds.g.cs index 5279e7b4923..c6f75e0e6f3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoBounds.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoBounds.g.cs @@ -30,6 +30,9 @@ namespace Elastic.Clients.Elasticsearch; +/// +/// A geo bounding box. It can be represented in various ways:
- as 4 top/bottom/left/right coordinates
- as 2 top_left / bottom_right points
- as 2 top_right / bottom_left points
- as a WKT bounding box
+///
[JsonConverter(typeof(GeoBoundsConverter))] public sealed partial class GeoBounds : IComplexUnion { diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoLocation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoLocation.g.cs index 1af4db9dad7..1e9b850410e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoLocation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoLocation.g.cs @@ -30,6 +30,9 @@ namespace Elastic.Clients.Elasticsearch; +/// +/// A latitude/longitude as a 2 dimensional point. It can be represented in various ways:
- as a `{lat, long}` object
- as a geo hash value
- as a `[lon, lat]` array
- as a string in `", "` or WKT point formats
+///
[JsonConverter(typeof(GeoLocationConverter))] public sealed partial class GeoLocation : IComplexUnion { diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/MappingStats.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/MappingStats.g.cs new file mode 100644 index 00000000000..62b8fdb09c2 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/MappingStats.g.cs @@ -0,0 +1,38 @@ +// 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. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.IndexManagement; + +public sealed partial class MappingStats +{ + [JsonInclude, JsonPropertyName("total_count")] + public long TotalCount { get; init; } + [JsonInclude, JsonPropertyName("total_estimated_overhead")] + public Elastic.Clients.Elasticsearch.ByteSize? TotalEstimatedOverhead { get; init; } + [JsonInclude, JsonPropertyName("total_estimated_overhead_in_bytes")] + public long TotalEstimatedOverheadInBytes { get; init; } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/RolloverConditions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/RolloverConditions.g.cs index 3e5d2c8e716..f74050c9045 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/RolloverConditions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/RolloverConditions.g.cs @@ -39,10 +39,12 @@ public sealed partial class RolloverConditions public long? MaxPrimaryShardDocs { get; set; } [JsonInclude, JsonPropertyName("max_primary_shard_size")] public Elastic.Clients.Elasticsearch.ByteSize? MaxPrimaryShardSize { get; set; } + [JsonInclude, JsonPropertyName("max_primary_shard_size_bytes")] + public long? MaxPrimaryShardSizeBytes { get; set; } [JsonInclude, JsonPropertyName("max_size")] public Elastic.Clients.Elasticsearch.ByteSize? MaxSize { get; set; } [JsonInclude, JsonPropertyName("max_size_bytes")] - public Elastic.Clients.Elasticsearch.ByteSize? MaxSizeBytes { get; set; } + public long? MaxSizeBytes { get; set; } [JsonInclude, JsonPropertyName("min_age")] public Elastic.Clients.Elasticsearch.Duration? MinAge { get; set; } [JsonInclude, JsonPropertyName("min_docs")] @@ -51,8 +53,12 @@ public sealed partial class RolloverConditions public long? MinPrimaryShardDocs { get; set; } [JsonInclude, JsonPropertyName("min_primary_shard_size")] public Elastic.Clients.Elasticsearch.ByteSize? MinPrimaryShardSize { get; set; } + [JsonInclude, JsonPropertyName("min_primary_shard_size_bytes")] + public long? MinPrimaryShardSizeBytes { get; set; } [JsonInclude, JsonPropertyName("min_size")] public Elastic.Clients.Elasticsearch.ByteSize? MinSize { get; set; } + [JsonInclude, JsonPropertyName("min_size_bytes")] + public long? MinSizeBytes { get; set; } } public sealed partial class RolloverConditionsDescriptor : SerializableDescriptor @@ -68,13 +74,16 @@ public RolloverConditionsDescriptor() : base() private long? MaxDocsValue { get; set; } private long? MaxPrimaryShardDocsValue { get; set; } private Elastic.Clients.Elasticsearch.ByteSize? MaxPrimaryShardSizeValue { get; set; } + private long? MaxPrimaryShardSizeBytesValue { get; set; } private Elastic.Clients.Elasticsearch.ByteSize? MaxSizeValue { get; set; } - private Elastic.Clients.Elasticsearch.ByteSize? MaxSizeBytesValue { get; set; } + private long? MaxSizeBytesValue { get; set; } private Elastic.Clients.Elasticsearch.Duration? MinAgeValue { get; set; } private long? MinDocsValue { get; set; } private long? MinPrimaryShardDocsValue { get; set; } private Elastic.Clients.Elasticsearch.ByteSize? MinPrimaryShardSizeValue { get; set; } + private long? MinPrimaryShardSizeBytesValue { get; set; } private Elastic.Clients.Elasticsearch.ByteSize? MinSizeValue { get; set; } + private long? MinSizeBytesValue { get; set; } public RolloverConditionsDescriptor MaxAge(Elastic.Clients.Elasticsearch.Duration? maxAge) { @@ -106,13 +115,19 @@ public RolloverConditionsDescriptor MaxPrimaryShardSize(Elastic.Clients.Elastics return Self; } + public RolloverConditionsDescriptor MaxPrimaryShardSizeBytes(long? maxPrimaryShardSizeBytes) + { + MaxPrimaryShardSizeBytesValue = maxPrimaryShardSizeBytes; + return Self; + } + public RolloverConditionsDescriptor MaxSize(Elastic.Clients.Elasticsearch.ByteSize? maxSize) { MaxSizeValue = maxSize; return Self; } - public RolloverConditionsDescriptor MaxSizeBytes(Elastic.Clients.Elasticsearch.ByteSize? maxSizeBytes) + public RolloverConditionsDescriptor MaxSizeBytes(long? maxSizeBytes) { MaxSizeBytesValue = maxSizeBytes; return Self; @@ -142,12 +157,24 @@ public RolloverConditionsDescriptor MinPrimaryShardSize(Elastic.Clients.Elastics return Self; } + public RolloverConditionsDescriptor MinPrimaryShardSizeBytes(long? minPrimaryShardSizeBytes) + { + MinPrimaryShardSizeBytesValue = minPrimaryShardSizeBytes; + return Self; + } + public RolloverConditionsDescriptor MinSize(Elastic.Clients.Elasticsearch.ByteSize? minSize) { MinSizeValue = minSize; return Self; } + public RolloverConditionsDescriptor MinSizeBytes(long? minSizeBytes) + { + MinSizeBytesValue = minSizeBytes; + return Self; + } + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { writer.WriteStartObject(); @@ -181,16 +208,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MaxPrimaryShardSizeValue, options); } + if (MaxPrimaryShardSizeBytesValue.HasValue) + { + writer.WritePropertyName("max_primary_shard_size_bytes"); + writer.WriteNumberValue(MaxPrimaryShardSizeBytesValue.Value); + } + if (MaxSizeValue is not null) { writer.WritePropertyName("max_size"); JsonSerializer.Serialize(writer, MaxSizeValue, options); } - if (MaxSizeBytesValue is not null) + if (MaxSizeBytesValue.HasValue) { writer.WritePropertyName("max_size_bytes"); - JsonSerializer.Serialize(writer, MaxSizeBytesValue, options); + writer.WriteNumberValue(MaxSizeBytesValue.Value); } if (MinAgeValue is not null) @@ -217,12 +250,24 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, MinPrimaryShardSizeValue, options); } + if (MinPrimaryShardSizeBytesValue.HasValue) + { + writer.WritePropertyName("min_primary_shard_size_bytes"); + writer.WriteNumberValue(MinPrimaryShardSizeBytesValue.Value); + } + if (MinSizeValue is not null) { writer.WritePropertyName("min_size"); JsonSerializer.Serialize(writer, MinSizeValue, options); } + if (MinSizeBytesValue.HasValue) + { + writer.WritePropertyName("min_size_bytes"); + writer.WriteNumberValue(MinSizeBytesValue.Value); + } + writer.WriteEndObject(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStats.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStats.g.cs index b070da02514..7edc1e0946d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStats.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStats.g.cs @@ -47,6 +47,8 @@ public sealed partial class ShardStats public Elastic.Clients.Elasticsearch.IndexingStats? Indexing { get; init; } [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.IndexManagement.IndicesStats? Indices { get; init; } + [JsonInclude, JsonPropertyName("mappings")] + public Elastic.Clients.Elasticsearch.IndexManagement.MappingStats? Mappings { get; init; } [JsonInclude, JsonPropertyName("merges")] public Elastic.Clients.Elasticsearch.MergesStats? Merges { get; init; } [JsonInclude, JsonPropertyName("query_cache")] @@ -70,7 +72,8 @@ public sealed partial class ShardStats [JsonInclude, JsonPropertyName("shard_path")] public Elastic.Clients.Elasticsearch.IndexManagement.ShardPath? ShardPath { get; init; } [JsonInclude, JsonPropertyName("shards")] - public Elastic.Clients.Elasticsearch.IndexManagement.ShardsTotalStats? Shards { get; init; } + [ReadOnlyIndexNameDictionaryConverter(typeof(object))] + public IReadOnlyDictionary? Shards { get; init; } [JsonInclude, JsonPropertyName("store")] public Elastic.Clients.Elasticsearch.StoreStats? Store { get; init; } [JsonInclude, JsonPropertyName("translog")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexingStats.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexingStats.g.cs index 5771c76dcda..7169dd4581f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexingStats.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexingStats.g.cs @@ -57,4 +57,6 @@ public sealed partial class IndexingStats public long ThrottleTimeInMillis { get; init; } [JsonInclude, JsonPropertyName("types")] public IReadOnlyDictionary? Types { get; init; } + [JsonInclude, JsonPropertyName("write_load")] + public double? WriteLoad { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnQuery.g.cs index ae7f87c88ba..a0d239f009f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnQuery.g.cs @@ -63,7 +63,13 @@ public sealed partial class KnnQuery /// The query vector /// [JsonInclude, JsonPropertyName("query_vector")] - public ICollection QueryVector { get; set; } + public ICollection? QueryVector { get; set; } + + /// + /// The query vector builder. You must provide a query_vector_builder or query_vector, but not both. + /// + [JsonInclude, JsonPropertyName("query_vector_builder")] + public Elastic.Clients.Elasticsearch.QueryVectorBuilder? QueryVectorBuilder { get; set; } } public sealed partial class KnnQueryDescriptor : SerializableDescriptor> @@ -82,7 +88,10 @@ public KnnQueryDescriptor() : base() private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private long kValue { get; set; } private long NumCandidatesValue { get; set; } - private ICollection QueryVectorValue { get; set; } + private ICollection? QueryVectorValue { get; set; } + private Elastic.Clients.Elasticsearch.QueryVectorBuilder? QueryVectorBuilderValue { get; set; } + private QueryVectorBuilderDescriptor QueryVectorBuilderDescriptor { get; set; } + private Action QueryVectorBuilderDescriptorAction { get; set; } /// /// Filters for the kNN search query @@ -171,12 +180,39 @@ public KnnQueryDescriptor NumCandidates(long numCandidates) /// /// The query vector /// - public KnnQueryDescriptor QueryVector(ICollection queryVector) + public KnnQueryDescriptor QueryVector(ICollection? queryVector) { QueryVectorValue = queryVector; return Self; } + /// + /// The query vector builder. You must provide a query_vector_builder or query_vector, but not both. + /// + public KnnQueryDescriptor QueryVectorBuilder(Elastic.Clients.Elasticsearch.QueryVectorBuilder? queryVectorBuilder) + { + QueryVectorBuilderDescriptor = null; + QueryVectorBuilderDescriptorAction = null; + QueryVectorBuilderValue = queryVectorBuilder; + return Self; + } + + public KnnQueryDescriptor QueryVectorBuilder(QueryVectorBuilderDescriptor descriptor) + { + QueryVectorBuilderValue = null; + QueryVectorBuilderDescriptorAction = null; + QueryVectorBuilderDescriptor = descriptor; + return Self; + } + + public KnnQueryDescriptor QueryVectorBuilder(Action configure) + { + QueryVectorBuilderValue = null; + QueryVectorBuilderDescriptor = null; + QueryVectorBuilderDescriptorAction = configure; + return Self; + } + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { writer.WriteStartObject(); @@ -221,8 +257,28 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteNumberValue(kValue); writer.WritePropertyName("num_candidates"); writer.WriteNumberValue(NumCandidatesValue); - writer.WritePropertyName("query_vector"); - JsonSerializer.Serialize(writer, QueryVectorValue, options); + if (QueryVectorValue is not null) + { + writer.WritePropertyName("query_vector"); + JsonSerializer.Serialize(writer, QueryVectorValue, options); + } + + if (QueryVectorBuilderDescriptor is not null) + { + writer.WritePropertyName("query_vector_builder"); + JsonSerializer.Serialize(writer, QueryVectorBuilderDescriptor, options); + } + else if (QueryVectorBuilderDescriptorAction is not null) + { + writer.WritePropertyName("query_vector_builder"); + JsonSerializer.Serialize(writer, new QueryVectorBuilderDescriptor(QueryVectorBuilderDescriptorAction), options); + } + else if (QueryVectorBuilderValue is not null) + { + writer.WritePropertyName("query_vector_builder"); + JsonSerializer.Serialize(writer, QueryVectorBuilderValue, options); + } + writer.WriteEndObject(); } } @@ -243,7 +299,10 @@ public KnnQueryDescriptor() : base() private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } private long kValue { get; set; } private long NumCandidatesValue { get; set; } - private ICollection QueryVectorValue { get; set; } + private ICollection? QueryVectorValue { get; set; } + private Elastic.Clients.Elasticsearch.QueryVectorBuilder? QueryVectorBuilderValue { get; set; } + private QueryVectorBuilderDescriptor QueryVectorBuilderDescriptor { get; set; } + private Action QueryVectorBuilderDescriptorAction { get; set; } /// /// Filters for the kNN search query @@ -341,12 +400,39 @@ public KnnQueryDescriptor NumCandidates(long numCandidates) /// /// The query vector /// - public KnnQueryDescriptor QueryVector(ICollection queryVector) + public KnnQueryDescriptor QueryVector(ICollection? queryVector) { QueryVectorValue = queryVector; return Self; } + /// + /// The query vector builder. You must provide a query_vector_builder or query_vector, but not both. + /// + public KnnQueryDescriptor QueryVectorBuilder(Elastic.Clients.Elasticsearch.QueryVectorBuilder? queryVectorBuilder) + { + QueryVectorBuilderDescriptor = null; + QueryVectorBuilderDescriptorAction = null; + QueryVectorBuilderValue = queryVectorBuilder; + return Self; + } + + public KnnQueryDescriptor QueryVectorBuilder(QueryVectorBuilderDescriptor descriptor) + { + QueryVectorBuilderValue = null; + QueryVectorBuilderDescriptorAction = null; + QueryVectorBuilderDescriptor = descriptor; + return Self; + } + + public KnnQueryDescriptor QueryVectorBuilder(Action configure) + { + QueryVectorBuilderValue = null; + QueryVectorBuilderDescriptor = null; + QueryVectorBuilderDescriptorAction = configure; + return Self; + } + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { writer.WriteStartObject(); @@ -391,8 +477,28 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o writer.WriteNumberValue(kValue); writer.WritePropertyName("num_candidates"); writer.WriteNumberValue(NumCandidatesValue); - writer.WritePropertyName("query_vector"); - JsonSerializer.Serialize(writer, QueryVectorValue, options); + if (QueryVectorValue is not null) + { + writer.WritePropertyName("query_vector"); + JsonSerializer.Serialize(writer, QueryVectorValue, options); + } + + if (QueryVectorBuilderDescriptor is not null) + { + writer.WritePropertyName("query_vector_builder"); + JsonSerializer.Serialize(writer, QueryVectorBuilderDescriptor, options); + } + else if (QueryVectorBuilderDescriptorAction is not null) + { + writer.WritePropertyName("query_vector_builder"); + JsonSerializer.Serialize(writer, new QueryVectorBuilderDescriptor(QueryVectorBuilderDescriptorAction), options); + } + else if (QueryVectorBuilderValue is not null) + { + writer.WritePropertyName("query_vector_builder"); + JsonSerializer.Serialize(writer, QueryVectorBuilderValue, options); + } + writer.WriteEndObject(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeField.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeField.g.cs index 5586d2355a5..6238e52d240 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeField.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeField.g.cs @@ -29,14 +29,228 @@ namespace Elastic.Clients.Elasticsearch.Mapping; public sealed partial class RuntimeField { + /// + /// For type `lookup` + /// + [JsonInclude, JsonPropertyName("fetch_fields")] + public ICollection? FetchFields { get; set; } [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } + + /// + /// For type `lookup` + /// + [JsonInclude, JsonPropertyName("input_field")] + public Elastic.Clients.Elasticsearch.Field? InputField { get; set; } [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } + + /// + /// For type `lookup` + /// + [JsonInclude, JsonPropertyName("target_field")] + public Elastic.Clients.Elasticsearch.Field? TargetField { get; set; } + + /// + /// For type `lookup` + /// + [JsonInclude, JsonPropertyName("target_index")] + public Elastic.Clients.Elasticsearch.IndexName? TargetIndex { get; set; } [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.Mapping.RuntimeFieldType Type { get; set; } } +public sealed partial class RuntimeFieldDescriptor : SerializableDescriptor> +{ + internal RuntimeFieldDescriptor(Action> configure) => configure.Invoke(this); + + public RuntimeFieldDescriptor() : base() + { + } + + private ICollection? FetchFieldsValue { get; set; } + private RuntimeFieldFetchFieldsDescriptor FetchFieldsDescriptor { get; set; } + private Action> FetchFieldsDescriptorAction { get; set; } + private Action>[] FetchFieldsDescriptorActions { get; set; } + private string? FormatValue { get; set; } + private Elastic.Clients.Elasticsearch.Field? InputFieldValue { get; set; } + private Elastic.Clients.Elasticsearch.Script? ScriptValue { get; set; } + private Elastic.Clients.Elasticsearch.Field? TargetFieldValue { get; set; } + private Elastic.Clients.Elasticsearch.IndexName? TargetIndexValue { get; set; } + private Elastic.Clients.Elasticsearch.Mapping.RuntimeFieldType TypeValue { get; set; } + + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor FetchFields(ICollection? fetchFields) + { + FetchFieldsDescriptor = null; + FetchFieldsDescriptorAction = null; + FetchFieldsDescriptorActions = null; + FetchFieldsValue = fetchFields; + return Self; + } + + public RuntimeFieldDescriptor FetchFields(RuntimeFieldFetchFieldsDescriptor descriptor) + { + FetchFieldsValue = null; + FetchFieldsDescriptorAction = null; + FetchFieldsDescriptorActions = null; + FetchFieldsDescriptor = descriptor; + return Self; + } + + public RuntimeFieldDescriptor FetchFields(Action> configure) + { + FetchFieldsValue = null; + FetchFieldsDescriptor = null; + FetchFieldsDescriptorActions = null; + FetchFieldsDescriptorAction = configure; + return Self; + } + + public RuntimeFieldDescriptor FetchFields(params Action>[] configure) + { + FetchFieldsValue = null; + FetchFieldsDescriptor = null; + FetchFieldsDescriptorAction = null; + FetchFieldsDescriptorActions = configure; + return Self; + } + + public RuntimeFieldDescriptor Format(string? format) + { + FormatValue = format; + return Self; + } + + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor InputField(Elastic.Clients.Elasticsearch.Field? inputField) + { + InputFieldValue = inputField; + return Self; + } + + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor InputField(Expression> inputField) + { + InputFieldValue = inputField; + return Self; + } + + public RuntimeFieldDescriptor Script(Elastic.Clients.Elasticsearch.Script? script) + { + ScriptValue = script; + return Self; + } + + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor TargetField(Elastic.Clients.Elasticsearch.Field? targetField) + { + TargetFieldValue = targetField; + return Self; + } + + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor TargetField(Expression> targetField) + { + TargetFieldValue = targetField; + return Self; + } + + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor TargetIndex(Elastic.Clients.Elasticsearch.IndexName? targetIndex) + { + TargetIndexValue = targetIndex; + return Self; + } + + public RuntimeFieldDescriptor Type(Elastic.Clients.Elasticsearch.Mapping.RuntimeFieldType type) + { + TypeValue = type; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + if (FetchFieldsDescriptor is not null) + { + writer.WritePropertyName("fetch_fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, FetchFieldsDescriptor, options); + writer.WriteEndArray(); + } + else if (FetchFieldsDescriptorAction is not null) + { + writer.WritePropertyName("fetch_fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, new RuntimeFieldFetchFieldsDescriptor(FetchFieldsDescriptorAction), options); + writer.WriteEndArray(); + } + else if (FetchFieldsDescriptorActions is not null) + { + writer.WritePropertyName("fetch_fields"); + writer.WriteStartArray(); + foreach (var action in FetchFieldsDescriptorActions) + { + JsonSerializer.Serialize(writer, new RuntimeFieldFetchFieldsDescriptor(action), options); + } + + writer.WriteEndArray(); + } + else if (FetchFieldsValue is not null) + { + writer.WritePropertyName("fetch_fields"); + JsonSerializer.Serialize(writer, FetchFieldsValue, options); + } + + if (!string.IsNullOrEmpty(FormatValue)) + { + writer.WritePropertyName("format"); + writer.WriteStringValue(FormatValue); + } + + if (InputFieldValue is not null) + { + writer.WritePropertyName("input_field"); + JsonSerializer.Serialize(writer, InputFieldValue, options); + } + + if (ScriptValue is not null) + { + writer.WritePropertyName("script"); + JsonSerializer.Serialize(writer, ScriptValue, options); + } + + if (TargetFieldValue is not null) + { + writer.WritePropertyName("target_field"); + JsonSerializer.Serialize(writer, TargetFieldValue, options); + } + + if (TargetIndexValue is not null) + { + writer.WritePropertyName("target_index"); + JsonSerializer.Serialize(writer, TargetIndexValue, options); + } + + writer.WritePropertyName("type"); + JsonSerializer.Serialize(writer, TypeValue, options); + writer.WriteEndObject(); + } +} + public sealed partial class RuntimeFieldDescriptor : SerializableDescriptor { internal RuntimeFieldDescriptor(Action configure) => configure.Invoke(this); @@ -45,22 +259,131 @@ public RuntimeFieldDescriptor() : base() { } + private ICollection? FetchFieldsValue { get; set; } + private RuntimeFieldFetchFieldsDescriptor FetchFieldsDescriptor { get; set; } + private Action FetchFieldsDescriptorAction { get; set; } + private Action[] FetchFieldsDescriptorActions { get; set; } private string? FormatValue { get; set; } + private Elastic.Clients.Elasticsearch.Field? InputFieldValue { get; set; } private Elastic.Clients.Elasticsearch.Script? ScriptValue { get; set; } + private Elastic.Clients.Elasticsearch.Field? TargetFieldValue { get; set; } + private Elastic.Clients.Elasticsearch.IndexName? TargetIndexValue { get; set; } private Elastic.Clients.Elasticsearch.Mapping.RuntimeFieldType TypeValue { get; set; } + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor FetchFields(ICollection? fetchFields) + { + FetchFieldsDescriptor = null; + FetchFieldsDescriptorAction = null; + FetchFieldsDescriptorActions = null; + FetchFieldsValue = fetchFields; + return Self; + } + + public RuntimeFieldDescriptor FetchFields(RuntimeFieldFetchFieldsDescriptor descriptor) + { + FetchFieldsValue = null; + FetchFieldsDescriptorAction = null; + FetchFieldsDescriptorActions = null; + FetchFieldsDescriptor = descriptor; + return Self; + } + + public RuntimeFieldDescriptor FetchFields(Action configure) + { + FetchFieldsValue = null; + FetchFieldsDescriptor = null; + FetchFieldsDescriptorActions = null; + FetchFieldsDescriptorAction = configure; + return Self; + } + + public RuntimeFieldDescriptor FetchFields(params Action[] configure) + { + FetchFieldsValue = null; + FetchFieldsDescriptor = null; + FetchFieldsDescriptorAction = null; + FetchFieldsDescriptorActions = configure; + return Self; + } + public RuntimeFieldDescriptor Format(string? format) { FormatValue = format; return Self; } + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor InputField(Elastic.Clients.Elasticsearch.Field? inputField) + { + InputFieldValue = inputField; + return Self; + } + + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor InputField(Expression> inputField) + { + InputFieldValue = inputField; + return Self; + } + + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor InputField(Expression> inputField) + { + InputFieldValue = inputField; + return Self; + } + public RuntimeFieldDescriptor Script(Elastic.Clients.Elasticsearch.Script? script) { ScriptValue = script; return Self; } + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor TargetField(Elastic.Clients.Elasticsearch.Field? targetField) + { + TargetFieldValue = targetField; + return Self; + } + + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor TargetField(Expression> targetField) + { + TargetFieldValue = targetField; + return Self; + } + + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor TargetField(Expression> targetField) + { + TargetFieldValue = targetField; + return Self; + } + + /// + /// For type `lookup` + /// + public RuntimeFieldDescriptor TargetIndex(Elastic.Clients.Elasticsearch.IndexName? targetIndex) + { + TargetIndexValue = targetIndex; + return Self; + } + public RuntimeFieldDescriptor Type(Elastic.Clients.Elasticsearch.Mapping.RuntimeFieldType type) { TypeValue = type; @@ -70,18 +393,67 @@ public RuntimeFieldDescriptor Type(Elastic.Clients.Elasticsearch.Mapping.Runtime protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { writer.WriteStartObject(); + if (FetchFieldsDescriptor is not null) + { + writer.WritePropertyName("fetch_fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, FetchFieldsDescriptor, options); + writer.WriteEndArray(); + } + else if (FetchFieldsDescriptorAction is not null) + { + writer.WritePropertyName("fetch_fields"); + writer.WriteStartArray(); + JsonSerializer.Serialize(writer, new RuntimeFieldFetchFieldsDescriptor(FetchFieldsDescriptorAction), options); + writer.WriteEndArray(); + } + else if (FetchFieldsDescriptorActions is not null) + { + writer.WritePropertyName("fetch_fields"); + writer.WriteStartArray(); + foreach (var action in FetchFieldsDescriptorActions) + { + JsonSerializer.Serialize(writer, new RuntimeFieldFetchFieldsDescriptor(action), options); + } + + writer.WriteEndArray(); + } + else if (FetchFieldsValue is not null) + { + writer.WritePropertyName("fetch_fields"); + JsonSerializer.Serialize(writer, FetchFieldsValue, options); + } + if (!string.IsNullOrEmpty(FormatValue)) { writer.WritePropertyName("format"); writer.WriteStringValue(FormatValue); } + if (InputFieldValue is not null) + { + writer.WritePropertyName("input_field"); + JsonSerializer.Serialize(writer, InputFieldValue, options); + } + if (ScriptValue is not null) { writer.WritePropertyName("script"); JsonSerializer.Serialize(writer, ScriptValue, options); } + if (TargetFieldValue is not null) + { + writer.WritePropertyName("target_field"); + JsonSerializer.Serialize(writer, TargetFieldValue, options); + } + + if (TargetIndexValue is not null) + { + writer.WritePropertyName("target_index"); + JsonSerializer.Serialize(writer, TargetIndexValue, options); + } + writer.WritePropertyName("type"); JsonSerializer.Serialize(writer, TypeValue, options); writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs new file mode 100644 index 00000000000..f5625d725c7 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs @@ -0,0 +1,130 @@ +// 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. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.Mapping; + +public sealed partial class RuntimeFieldFetchFields +{ + [JsonInclude, JsonPropertyName("field")] + public Elastic.Clients.Elasticsearch.Field Field { get; set; } + [JsonInclude, JsonPropertyName("format")] + public string? Format { get; set; } +} + +public sealed partial class RuntimeFieldFetchFieldsDescriptor : SerializableDescriptor> +{ + internal RuntimeFieldFetchFieldsDescriptor(Action> configure) => configure.Invoke(this); + + public RuntimeFieldFetchFieldsDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } + private string? FormatValue { get; set; } + + public RuntimeFieldFetchFieldsDescriptor Field(Elastic.Clients.Elasticsearch.Field field) + { + FieldValue = field; + return Self; + } + + public RuntimeFieldFetchFieldsDescriptor Field(Expression> field) + { + FieldValue = field; + return Self; + } + + public RuntimeFieldFetchFieldsDescriptor Format(string? format) + { + FormatValue = format; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + writer.WritePropertyName("field"); + JsonSerializer.Serialize(writer, FieldValue, options); + if (!string.IsNullOrEmpty(FormatValue)) + { + writer.WritePropertyName("format"); + writer.WriteStringValue(FormatValue); + } + + writer.WriteEndObject(); + } +} + +public sealed partial class RuntimeFieldFetchFieldsDescriptor : SerializableDescriptor +{ + internal RuntimeFieldFetchFieldsDescriptor(Action configure) => configure.Invoke(this); + + public RuntimeFieldFetchFieldsDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; } + private string? FormatValue { get; set; } + + public RuntimeFieldFetchFieldsDescriptor Field(Elastic.Clients.Elasticsearch.Field field) + { + FieldValue = field; + return Self; + } + + public RuntimeFieldFetchFieldsDescriptor Field(Expression> field) + { + FieldValue = field; + return Self; + } + + public RuntimeFieldFetchFieldsDescriptor Field(Expression> field) + { + FieldValue = field; + return Self; + } + + public RuntimeFieldFetchFieldsDescriptor Format(string? format) + { + FormatValue = format; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + writer.WritePropertyName("field"); + JsonSerializer.Serialize(writer, FieldValue, options); + if (!string.IsNullOrEmpty(FormatValue)) + { + writer.WritePropertyName("format"); + writer.WriteStringValue(FormatValue); + } + + 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 727f58d19e4..99ab97c6976 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NerInferenceOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/NerInferenceOptions.g.cs @@ -49,6 +49,8 @@ public sealed partial class NerInferenceOptions /// [JsonInclude, JsonPropertyName("tokenization")] public Elastic.Clients.Elasticsearch.Ml.TokenizationConfig? Tokenization { get; set; } + [JsonInclude, JsonPropertyName("vocabulary")] + public Elastic.Clients.Elasticsearch.Ml.Vocabulary? Vocabulary { get; set; } public static implicit operator InferenceConfigCreate(NerInferenceOptions nerInferenceOptions) => Ml.InferenceConfigCreate.Ner(nerInferenceOptions); } @@ -69,6 +71,9 @@ public NerInferenceOptionsDescriptor() : base() private Elastic.Clients.Elasticsearch.Ml.TokenizationConfig? TokenizationValue { get; set; } private TokenizationConfigDescriptor TokenizationDescriptor { get; set; } private Action TokenizationDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Ml.Vocabulary? VocabularyValue { get; set; } + private VocabularyDescriptor VocabularyDescriptor { get; set; } + private Action VocabularyDescriptorAction { get; set; } /// /// The token classification labels. Must be IOB formatted tags @@ -115,6 +120,30 @@ public NerInferenceOptionsDescriptor Tokenization(Action configure) + { + VocabularyValue = null; + VocabularyDescriptor = null; + VocabularyDescriptorAction = configure; + return Self; + } + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { writer.WriteStartObject(); @@ -146,6 +175,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, TokenizationValue, options); } + if (VocabularyDescriptor is not null) + { + writer.WritePropertyName("vocabulary"); + JsonSerializer.Serialize(writer, VocabularyDescriptor, options); + } + else if (VocabularyDescriptorAction is not null) + { + writer.WritePropertyName("vocabulary"); + JsonSerializer.Serialize(writer, new VocabularyDescriptor(VocabularyDescriptorAction), options); + } + else if (VocabularyValue is not null) + { + writer.WritePropertyName("vocabulary"); + JsonSerializer.Serialize(writer, VocabularyValue, options); + } + writer.WriteEndObject(); } } \ No newline at end of file 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 c08e0c93d3f..3be92c12bba 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/PassThroughInferenceOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/PassThroughInferenceOptions.g.cs @@ -43,6 +43,8 @@ public sealed partial class PassThroughInferenceOptions /// [JsonInclude, JsonPropertyName("tokenization")] public Elastic.Clients.Elasticsearch.Ml.TokenizationConfig? Tokenization { get; set; } + [JsonInclude, JsonPropertyName("vocabulary")] + public Elastic.Clients.Elasticsearch.Ml.Vocabulary? Vocabulary { get; set; } public static implicit operator InferenceConfigCreate(PassThroughInferenceOptions passThroughInferenceOptions) => Ml.InferenceConfigCreate.PassThrough(passThroughInferenceOptions); } @@ -62,6 +64,9 @@ public PassThroughInferenceOptionsDescriptor() : base() private Elastic.Clients.Elasticsearch.Ml.TokenizationConfig? TokenizationValue { get; set; } private TokenizationConfigDescriptor TokenizationDescriptor { get; set; } private Action TokenizationDescriptorAction { get; set; } + private Elastic.Clients.Elasticsearch.Ml.Vocabulary? VocabularyValue { get; set; } + private VocabularyDescriptor VocabularyDescriptor { get; set; } + private Action VocabularyDescriptorAction { get; set; } /// /// The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value. @@ -99,6 +104,30 @@ public PassThroughInferenceOptionsDescriptor Tokenization(Action configure) + { + VocabularyValue = null; + VocabularyDescriptor = null; + VocabularyDescriptorAction = configure; + return Self; + } + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { writer.WriteStartObject(); @@ -124,6 +153,22 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o JsonSerializer.Serialize(writer, TokenizationValue, options); } + if (VocabularyDescriptor is not null) + { + writer.WritePropertyName("vocabulary"); + JsonSerializer.Serialize(writer, VocabularyDescriptor, options); + } + else if (VocabularyDescriptorAction is not null) + { + writer.WritePropertyName("vocabulary"); + JsonSerializer.Serialize(writer, new VocabularyDescriptor(VocabularyDescriptorAction), options); + } + else if (VocabularyValue is not null) + { + writer.WritePropertyName("vocabulary"); + JsonSerializer.Serialize(writer, VocabularyValue, options); + } + writer.WriteEndObject(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/Vocabulary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/Vocabulary.g.cs new file mode 100644 index 00000000000..fbfb5c30e22 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ml/Vocabulary.g.cs @@ -0,0 +1,59 @@ +// 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. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.Ml; + +public sealed partial class Vocabulary +{ + [JsonInclude, JsonPropertyName("index")] + public Elastic.Clients.Elasticsearch.IndexName Index { get; set; } +} + +public sealed partial class VocabularyDescriptor : SerializableDescriptor +{ + internal VocabularyDescriptor(Action configure) => configure.Invoke(this); + + public VocabularyDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.IndexName IndexValue { get; set; } + + public VocabularyDescriptor Index(Elastic.Clients.Elasticsearch.IndexName index) + { + IndexValue = index; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + 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/NodeAttributes.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/NodeAttributes.g.cs index 9fc74dabad5..d30ea20b9dc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/NodeAttributes.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/NodeAttributes.g.cs @@ -41,7 +41,7 @@ public sealed partial class NodeAttributes [JsonInclude, JsonPropertyName("ephemeral_id")] public string EphemeralId { get; init; } [JsonInclude, JsonPropertyName("external_id")] - public string ExternalId { get; init; } + public string? ExternalId { get; init; } /// /// The unique identifier of the node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/NodeShard.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/NodeShard.g.cs index 344c0a7465e..5ddb7b4b44f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/NodeShard.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/NodeShard.g.cs @@ -41,6 +41,8 @@ public sealed partial class NodeShard public IReadOnlyDictionary? RecoverySource { get; init; } [JsonInclude, JsonPropertyName("relocating_node")] public string? RelocatingNode { get; init; } + [JsonInclude, JsonPropertyName("relocation_failure_info")] + public Elastic.Clients.Elasticsearch.RelocationFailureInfo? RelocationFailureInfo { get; init; } [JsonInclude, JsonPropertyName("shard")] public int Shard { get; init; } [JsonInclude, JsonPropertyName("state")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryVectorBuilder.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryVectorBuilder.g.cs new file mode 100644 index 00000000000..7d79d7a6f23 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryVectorBuilder.g.cs @@ -0,0 +1,206 @@ +// 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. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch; + +[JsonConverter(typeof(QueryVectorBuilderConverter))] +public sealed partial class QueryVectorBuilder +{ + internal QueryVectorBuilder(string variantName, object variant) + { + if (variantName is null) + throw new ArgumentNullException(nameof(variantName)); + if (variant is null) + throw new ArgumentNullException(nameof(variant)); + if (string.IsNullOrWhiteSpace(variantName)) + throw new ArgumentException("Variant name must not be empty or whitespace."); + VariantName = variantName; + Variant = variant; + } + + internal object Variant { get; } + internal string VariantName { get; } + + public static QueryVectorBuilder TextEmbedding(Elastic.Clients.Elasticsearch.TextEmbedding textEmbedding) => new QueryVectorBuilder("text_embedding", textEmbedding); +} + +internal sealed partial class QueryVectorBuilderConverter : JsonConverter +{ + public override QueryVectorBuilder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType != JsonTokenType.StartObject) + { + throw new JsonException("Expected start token."); + } + + reader.Read(); + if (reader.TokenType != JsonTokenType.PropertyName) + { + throw new JsonException("Expected a property name token representing the variant held within this container."); + } + + var propertyName = reader.GetString(); + reader.Read(); + if (propertyName == "text_embedding") + { + var variant = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); + return new QueryVectorBuilder(propertyName, variant); + } + + throw new JsonException(); + } + + public override void Write(Utf8JsonWriter writer, QueryVectorBuilder value, JsonSerializerOptions options) + { + writer.WriteStartObject(); + if (value.VariantName is not null & value.Variant is not null) + { + writer.WritePropertyName(value.VariantName); + switch (value.VariantName) + { + case "text_embedding": + JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.TextEmbedding)value.Variant, options); + break; + } + } + + writer.WriteEndObject(); + } +} + +public sealed partial class QueryVectorBuilderDescriptor : SerializableDescriptor> +{ + internal QueryVectorBuilderDescriptor(Action> configure) => configure.Invoke(this); + + public QueryVectorBuilderDescriptor() : base() + { + } + + private bool ContainsVariant { get; set; } + private string ContainedVariantName { get; set; } + private object Variant { get; set; } + private Descriptor Descriptor { get; set; } + + private QueryVectorBuilderDescriptor Set(Action descriptorAction, string variantName) where T : Descriptor + { + ContainedVariantName = variantName; + ContainsVariant = true; + var descriptor = (T)Activator.CreateInstance(typeof(T), true); + descriptorAction?.Invoke(descriptor); + Descriptor = descriptor; + return Self; + } + + private QueryVectorBuilderDescriptor Set(object variant, string variantName) + { + Variant = variant; + ContainedVariantName = variantName; + ContainsVariant = true; + return Self; + } + + public QueryVectorBuilderDescriptor TextEmbedding(TextEmbedding textEmbedding) => Set(textEmbedding, "text_embedding"); + public QueryVectorBuilderDescriptor TextEmbedding(Action configure) => Set(configure, "text_embedding"); + + 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); + writer.WriteEndObject(); + return; + } + + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + writer.WriteEndObject(); + } +} + +public sealed partial class QueryVectorBuilderDescriptor : SerializableDescriptor +{ + internal QueryVectorBuilderDescriptor(Action configure) => configure.Invoke(this); + + public QueryVectorBuilderDescriptor() : base() + { + } + + private bool ContainsVariant { get; set; } + private string ContainedVariantName { get; set; } + private object Variant { get; set; } + private Descriptor Descriptor { get; set; } + + private QueryVectorBuilderDescriptor Set(Action descriptorAction, string variantName) where T : Descriptor + { + ContainedVariantName = variantName; + ContainsVariant = true; + var descriptor = (T)Activator.CreateInstance(typeof(T), true); + descriptorAction?.Invoke(descriptor); + Descriptor = descriptor; + return Self; + } + + private QueryVectorBuilderDescriptor Set(object variant, string variantName) + { + Variant = variant; + ContainedVariantName = variantName; + ContainsVariant = true; + return Self; + } + + public QueryVectorBuilderDescriptor TextEmbedding(TextEmbedding textEmbedding) => Set(textEmbedding, "text_embedding"); + public QueryVectorBuilderDescriptor TextEmbedding(Action configure) => Set(configure, "text_embedding"); + + 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); + writer.WriteEndObject(); + return; + } + + JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options); + writer.WriteEndObject(); + } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/RelocationFailureInfo.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/RelocationFailureInfo.g.cs new file mode 100644 index 00000000000..5fdf68c44d5 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/RelocationFailureInfo.g.cs @@ -0,0 +1,34 @@ +// 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. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch; + +public sealed partial class RelocationFailureInfo +{ + [JsonInclude, JsonPropertyName("failed_attempts")] + public int FailedAttempts { get; init; } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/TextEmbedding.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TextEmbedding.g.cs new file mode 100644 index 00000000000..0b09b510989 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/TextEmbedding.g.cs @@ -0,0 +1,72 @@ +// 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. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch; + +public sealed partial class TextEmbedding +{ + [JsonInclude, JsonPropertyName("model_id")] + public string ModelId { get; set; } + [JsonInclude, JsonPropertyName("model_text")] + public string ModelText { get; set; } + + public static implicit operator QueryVectorBuilder(TextEmbedding textEmbedding) => QueryVectorBuilder.TextEmbedding(textEmbedding); +} + +public sealed partial class TextEmbeddingDescriptor : SerializableDescriptor +{ + internal TextEmbeddingDescriptor(Action configure) => configure.Invoke(this); + + public TextEmbeddingDescriptor() : base() + { + } + + private string ModelIdValue { get; set; } + private string ModelTextValue { get; set; } + + public TextEmbeddingDescriptor ModelId(string modelId) + { + ModelIdValue = modelId; + return Self; + } + + public TextEmbeddingDescriptor ModelText(string modelText) + { + ModelTextValue = modelText; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + writer.WritePropertyName("model_id"); + writer.WriteStringValue(ModelIdValue); + writer.WritePropertyName("model_text"); + writer.WriteStringValue(ModelTextValue); + writer.WriteEndObject(); + } +} \ No newline at end of file diff --git a/tests/Tests/Aggregations/AggregationMetaUsageTests.cs b/tests/Tests/Aggregations/AggregationMetaUsageTests.cs index 8d46ec1a90b..51bd78d832f 100644 --- a/tests/Tests/Aggregations/AggregationMetaUsageTests.cs +++ b/tests/Tests/Aggregations/AggregationMetaUsageTests.cs @@ -12,7 +12,9 @@ namespace Tests.Aggregations; +#pragma warning disable CS0618 // Type or member is obsolete public class AggregationMetaUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public AggregationMetaUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/AggregationUsageTestBase.cs b/tests/Tests/Aggregations/AggregationUsageTestBase.cs index bacb3d335e6..be2d57a9620 100644 --- a/tests/Tests/Aggregations/AggregationUsageTestBase.cs +++ b/tests/Tests/Aggregations/AggregationUsageTestBase.cs @@ -13,9 +13,10 @@ namespace Tests.Aggregations; +[Obsolete("Prefer AggregationUsageWithVerifyTestBase")] public abstract class AggregationUsageTestBase : ApiIntegrationTestBase, SearchRequestDescriptor, SearchRequest> - where TCluster : IEphemeralCluster, ITestCluster, new() + where TCluster : IEphemeralCluster, ITestCluster, new() { protected AggregationUsageTestBase(TCluster cluster, EndpointUsage usage) : base(cluster, usage) { } diff --git a/tests/Tests/Aggregations/AggregationUsageWithVerifyTestBase.cs b/tests/Tests/Aggregations/AggregationUsageWithVerifyTestBase.cs new file mode 100644 index 00000000000..2471893cf84 --- /dev/null +++ b/tests/Tests/Aggregations/AggregationUsageWithVerifyTestBase.cs @@ -0,0 +1,60 @@ +// 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 Elastic.Clients.Elasticsearch.Aggregations; +using Elastic.Clients.Elasticsearch.QueryDsl; +using Elastic.Elasticsearch.Ephemeral; +using Tests.Core.ManagedElasticsearch.Clusters; +using Tests.Domain; +using Tests.Framework.EndpointTests; +using Tests.Framework.EndpointTests.TestState; + +namespace Tests.Aggregations; + +public abstract class AggregationUsageWithVerifyTestBase + : ApiIntegrationTestBase, SearchRequestDescriptor, SearchRequest> + where TCluster : IEphemeralCluster, ITestCluster, new() +{ + protected AggregationUsageWithVerifyTestBase(TCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + + protected virtual Indices AgainstIndex { get; } = Infer.Index(); + + protected override bool VerifyJson => true; + protected override bool ExpectIsValid => true; + protected override int ExpectStatusCode => 200; + + protected override Action> Fluent => s => s + .Size(0) + .Index(AgainstIndex) + .Query(QueryScope) + .Aggregations(FluentAggregations); + + protected abstract Action> FluentAggregations { get; } + + protected override HttpMethod ExpectHttpMethod => HttpMethod.POST; + + protected override SearchRequest Initializer => + new(AgainstIndex) + { + Query = QueryScope, + Size = 0, + Aggregations = InitializerAggregations + }; + + protected abstract AggregationDictionary InitializerAggregations { get; } + + protected virtual Query QueryScope { get; } = new TermQuery("type") { Value = Project.TypeName }; + + protected virtual object QueryScopeJson { get; } = new { term = new { type = new { value = Project.TypeName } } }; + + protected override string ExpectedUrlPathAndQuery => $"/project/_search"; + + protected override LazyResponses ClientUsage() => Calls( + (client, f) => client.Search(f), + (client, f) => client.SearchAsync(f), + (client, r) => client.Search(r), + (client, r) => client.SearchAsync(r) + ); +} diff --git a/tests/Tests/Aggregations/Bucket/TermsAggregationUsageTests.cs b/tests/Tests/Aggregations/Bucket/TermsAggregationUsageTests.cs index 0b0d8c0f7f8..8d6883565f6 100644 --- a/tests/Tests/Aggregations/Bucket/TermsAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Bucket/TermsAggregationUsageTests.cs @@ -13,7 +13,9 @@ namespace Tests.Aggregations.Bucket; +#pragma warning disable CS0618 // Type or member is obsolete public class TermsAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public TermsAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/AverageAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/AverageAggregationUsageTests.cs index a860a071395..d0f73f718e8 100644 --- a/tests/Tests/Aggregations/Metric/AverageAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/AverageAggregationUsageTests.cs @@ -13,7 +13,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class AverageAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public AverageAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/BoxplotAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/BoxplotAggregationUsageTests.cs index adc1894f16f..ecf84725448 100644 --- a/tests/Tests/Aggregations/Metric/BoxplotAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/BoxplotAggregationUsageTests.cs @@ -13,7 +13,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class BoxplotAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public BoxplotAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/CardinalityAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/CardinalityAggregationUsageTests.cs index ae9852552c8..eff7e4d980c 100644 --- a/tests/Tests/Aggregations/Metric/CardinalityAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/CardinalityAggregationUsageTests.cs @@ -12,7 +12,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class CardinalityAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public CardinalityAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/ExtendedStatsAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/ExtendedStatsAggregationUsageTests.cs index 7567ab6f55e..47f8c15ea07 100644 --- a/tests/Tests/Aggregations/Metric/ExtendedStatsAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/ExtendedStatsAggregationUsageTests.cs @@ -13,7 +13,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class ExtendedStatsAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public ExtendedStatsAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/MaxAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/MaxAggregationUsageTests.cs index 3ce2d79cb15..4ddf7becf00 100644 --- a/tests/Tests/Aggregations/Metric/MaxAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/MaxAggregationUsageTests.cs @@ -13,7 +13,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class MaxAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public MaxAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/MedianAbsoluteDeviationAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/MedianAbsoluteDeviationAggregationUsageTests.cs index a87b12def90..6b0ee7c65ee 100644 --- a/tests/Tests/Aggregations/Metric/MedianAbsoluteDeviationAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/MedianAbsoluteDeviationAggregationUsageTests.cs @@ -11,7 +11,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class MedianAbsoluteDeviationAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public MedianAbsoluteDeviationAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/MinAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/MinAggregationUsageTests.cs index b14ed54563c..a746a43eac6 100644 --- a/tests/Tests/Aggregations/Metric/MinAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/MinAggregationUsageTests.cs @@ -12,7 +12,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class MinAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public MinAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/StatsAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/StatsAggregationUsageTests.cs index 893d303ba16..b68da3bbc83 100644 --- a/tests/Tests/Aggregations/Metric/StatsAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/StatsAggregationUsageTests.cs @@ -12,7 +12,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class StatsAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public StatsAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/StringStatsAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/StringStatsAggregationUsageTests.cs index c9d868930b0..7072dc83eb4 100644 --- a/tests/Tests/Aggregations/Metric/StringStatsAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/StringStatsAggregationUsageTests.cs @@ -12,7 +12,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class StringStatsAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public StringStatsAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/StringStatsWithDistributionAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/StringStatsWithDistributionAggregationUsageTests.cs index 52200dcdad3..9779771ef75 100644 --- a/tests/Tests/Aggregations/Metric/StringStatsWithDistributionAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/StringStatsWithDistributionAggregationUsageTests.cs @@ -12,7 +12,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class StringStatsWithDistributionAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public StringStatsWithDistributionAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/SumAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/SumAggregationUsageTests.cs index 9813888e4d1..0751e25445c 100644 --- a/tests/Tests/Aggregations/Metric/SumAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/SumAggregationUsageTests.cs @@ -13,7 +13,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class SumAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public SumAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/ValueCountAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/ValueCountAggregationUsageTests.cs index 0fbeed6a2a0..c59bb3d7a57 100644 --- a/tests/Tests/Aggregations/Metric/ValueCountAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/ValueCountAggregationUsageTests.cs @@ -13,7 +13,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class ValueCountAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public ValueCountAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Metric/WeightedAverageAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/WeightedAverageAggregationUsageTests.cs index 94cd1e73847..983a7c5820e 100644 --- a/tests/Tests/Aggregations/Metric/WeightedAverageAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/WeightedAverageAggregationUsageTests.cs @@ -13,7 +13,9 @@ namespace Tests.Aggregations.Metric; +#pragma warning disable CS0618 // Type or member is obsolete public class WeightedAverageAggregationUsageTests : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { public WeightedAverageAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { } diff --git a/tests/Tests/Aggregations/Pipeline/BucketSortAggregationUsageTests.cs b/tests/Tests/Aggregations/Pipeline/BucketSortAggregationUsageTests.cs index e4451312ac2..326a870f923 100644 --- a/tests/Tests/Aggregations/Pipeline/BucketSortAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Pipeline/BucketSortAggregationUsageTests.cs @@ -12,44 +12,11 @@ namespace Tests.Aggregations.Pipeline; -public class BucketSortAggregationUsageTests : AggregationUsageTestBase +public class BucketSortAggregationUsageTests : AggregationUsageWithVerifyTestBase { public BucketSortAggregationUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } - protected override object AggregationJson => new - { - projects_started_per_month = new - { - date_histogram = new - { - field = "startedOn", - calendar_interval = "month", - }, - aggregations = new - { - commits = new - { - sum = new - { - field = "numberOfCommits" - } - }, - commits_bucket_sort = new - { - bucket_sort = new - { - sort = new { commits = new { order = "desc" } }, - from = 0, - size = 3, - gap_policy = "insert_zeros" - } - } - } - } - }; - -#pragma warning disable 618, 612 - protected override Action> FluentAggs => a => a + protected override Action> FluentAggregations => a => a .DateHistogram("projects_started_per_month", dh => dh .Field(p => p.StartedOn) .CalendarInterval(CalendarInterval.Month) @@ -68,7 +35,7 @@ public BucketSortAggregationUsageTests(ReadOnlyCluster cluster, EndpointUsage us ) ); - protected override AggregationDictionary InitializerAggs => + protected override AggregationDictionary InitializerAggregations => new DateHistogramAggregation("projects_started_per_month") { Field = "startedOn", @@ -86,7 +53,6 @@ public BucketSortAggregationUsageTests(ReadOnlyCluster cluster, EndpointUsage us GapPolicy = GapPolicy.InsertZeros } }; -#pragma warning restore 618, 612 protected override void ExpectResponse(SearchResponse response) { diff --git a/tests/Tests/Aggregations/Pipeline/CumulativeSumAggregationUsageTests.cs b/tests/Tests/Aggregations/Pipeline/CumulativeSumAggregationUsageTests.cs new file mode 100644 index 00000000000..7e8a5c509d0 --- /dev/null +++ b/tests/Tests/Aggregations/Pipeline/CumulativeSumAggregationUsageTests.cs @@ -0,0 +1,68 @@ +// 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 Tests.Core.ManagedElasticsearch.Clusters; +using Tests.Domain; +using Tests.Framework.EndpointTests.TestState; +using Elastic.Clients.Elasticsearch.Aggregations; +using Tests.Core.Extensions; +using Xunit; + +namespace Tests.Aggregations.Pipeline; + +public class CumulativeSumAggregationUsageTests : AggregationUsageWithVerifyTestBase +{ + public CumulativeSumAggregationUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + + protected override bool CompareJsonStrings => true; + + protected override Action> FluentAggregations => a => a + .DateHistogram("projects_started_per_month", dh => dh + .Field(p => p.StartedOn) + .CalendarInterval(CalendarInterval.Month) + .Aggregations(aa => aa + .Sum("commits", sm => sm + .Field(p => p.NumberOfCommits) + ) + .CumulativeSum("cumulative_commits", d => d + .BucketsPath("commits") + ) + ) + ); + + protected override AggregationDictionary InitializerAggregations => + new DateHistogramAggregation("projects_started_per_month") + { + Field = "startedOn", + CalendarInterval = CalendarInterval.Month, + Aggregations = + new SumAggregation("commits", "numberOfCommits") && + new CumulativeSumAggregation("cumulative_commits") { BucketsPath = "commits" } + }; + + protected override void ExpectResponse(SearchResponse response) + { + response.ShouldBeValid(); + + var projectsPerMonth = response.Aggregations.GetDateHistogram("projects_started_per_month"); + projectsPerMonth.Should().NotBeNull(); + projectsPerMonth.Buckets.Should().NotBeNull(); + projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); + + foreach (var item in projectsPerMonth.Buckets) + { + item.TryGetValue("cumulative_commits", out var cumulative).Should().BeTrue(); + + if (cumulative is not SimpleValueAggregate simpleValue) + { + Assert.Fail("Expected cumulative_commits to be SimpleValueAggregate"); + return; + } + + simpleValue.Should().NotBeNull(); + simpleValue.Value.Should().NotBe(null); + } + } +} diff --git a/tests/Tests/Aggregations/ProjectsOnlyAggregationUsageTestBase.cs b/tests/Tests/Aggregations/ProjectsOnlyAggregationUsageTestBase.cs index 8ecdda40bf4..94a08ba0119 100644 --- a/tests/Tests/Aggregations/ProjectsOnlyAggregationUsageTestBase.cs +++ b/tests/Tests/Aggregations/ProjectsOnlyAggregationUsageTestBase.cs @@ -8,7 +8,9 @@ namespace Tests.Aggregations; +#pragma warning disable CS0618 // Type or member is obsolete public abstract class ProjectsOnlyAggregationUsageTestBase : AggregationUsageTestBase +#pragma warning restore CS0618 // Type or member is obsolete { protected ProjectsOnlyAggregationUsageTestBase(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } diff --git a/tests/Tests/Framework/EndpointTests/ApiTestBase.cs b/tests/Tests/Framework/EndpointTests/ApiTestBase.cs index 81495f2c38d..bf515794b49 100644 --- a/tests/Tests/Framework/EndpointTests/ApiTestBase.cs +++ b/tests/Tests/Framework/EndpointTests/ApiTestBase.cs @@ -29,6 +29,7 @@ protected ApiTestBase(TCluster cluster, EndpointUsage usage) : base(cluster, usa protected override object ExpectJson { get; } = null; protected virtual bool VerifyNdJson { get; } = false; protected virtual bool VerifyJson { get; } = false; + protected virtual bool CompareJsonStrings { get; } = false; protected virtual bool VerifyResponseObjects { get; } = false; protected override IReadOnlyList ExpectNdjson { get; } = null; @@ -36,25 +37,24 @@ protected ApiTestBase(TCluster cluster, EndpointUsage usage) : base(cluster, usa protected abstract HttpMethod ExpectHttpMethod { get; } protected abstract string ExpectedUrlPathAndQuery { get; } - // TODO - It would be useful to verify that the JSON is equivalent, but using a string - // comparison is too brittle due to potential for elements to be ordered differently. + // TODO - It would be nice to make this happen for all tests but using a string comparison is brittle due to + // potential for elements to be ordered differently. This is currently opt in. - //[U] - //protected virtual void VerifyInitializerAndDescriptorProduceIdenticalJson() - //{ - // if (VerifyJson) - // { - - // var initializerJson = SerializeUsingClient(Initializer); + [U] + protected virtual void InitializerAndDescriptorProduceIdenticalJson() + { + if (CompareJsonStrings) + { + var initializerJson = SerializeUsingClient(Initializer); - // var descriptor = NewDescriptor(); - // Fluent?.Invoke(descriptor); + var descriptor = NewDescriptor(); + Fluent?.Invoke(descriptor); - // var descriptorJson = SerializeUsingClient(descriptor); + var descriptorJson = SerializeUsingClient(descriptor); - // initializerJson.Equals(descriptorJson).Should().BeTrue(); - // } - //} + initializerJson.Should().Be(descriptorJson, because: "Expected the JSON string produced by the initializer serialization to match the descriptor serialization."); + } + } [U] protected virtual async Task VerifyInitializerJson() diff --git a/tests/Tests/_VerifySnapshots/BucketSortAggregationUsageTests.VerifyDescriptorJson.verified.txt b/tests/Tests/_VerifySnapshots/BucketSortAggregationUsageTests.VerifyDescriptorJson.verified.txt new file mode 100644 index 00000000000..86a9ad155bd --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BucketSortAggregationUsageTests.VerifyDescriptorJson.verified.txt @@ -0,0 +1,37 @@ +{ + aggregations: { + projects_started_per_month: { + aggregations: { + commits: { + sum: { + field: numberOfCommits + } + }, + commits_bucket_sort: { + bucket_sort: { + from: 0, + gap_policy: insert_zeros, + size: 3, + sort: { + commits: { + order: desc + } + } + } + } + }, + date_histogram: { + calendar_interval: month, + field: startedOn + } + } + }, + query: { + term: { + type: { + value: project + } + } + }, + size: 0 +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/BucketSortAggregationUsageTests.VerifyInitializerJson.verified.txt b/tests/Tests/_VerifySnapshots/BucketSortAggregationUsageTests.VerifyInitializerJson.verified.txt new file mode 100644 index 00000000000..86a9ad155bd --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BucketSortAggregationUsageTests.VerifyInitializerJson.verified.txt @@ -0,0 +1,37 @@ +{ + aggregations: { + projects_started_per_month: { + aggregations: { + commits: { + sum: { + field: numberOfCommits + } + }, + commits_bucket_sort: { + bucket_sort: { + from: 0, + gap_policy: insert_zeros, + size: 3, + sort: { + commits: { + order: desc + } + } + } + } + }, + date_histogram: { + calendar_interval: month, + field: startedOn + } + } + }, + query: { + term: { + type: { + value: project + } + } + }, + size: 0 +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/CumulativeSumAggregationUsageTests.VerifyDescriptorJson.verified.txt b/tests/Tests/_VerifySnapshots/CumulativeSumAggregationUsageTests.VerifyDescriptorJson.verified.txt new file mode 100644 index 00000000000..a0e1fc16da9 --- /dev/null +++ b/tests/Tests/_VerifySnapshots/CumulativeSumAggregationUsageTests.VerifyDescriptorJson.verified.txt @@ -0,0 +1,30 @@ +{ + aggregations: { + projects_started_per_month: { + aggregations: { + commits: { + sum: { + field: numberOfCommits + } + }, + cumulative_commits: { + cumulative_sum: { + buckets_path: commits + } + } + }, + date_histogram: { + calendar_interval: month, + field: startedOn + } + } + }, + query: { + term: { + type: { + value: project + } + } + }, + size: 0 +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/CumulativeSumAggregationUsageTests.VerifyInitializerJson.verified.txt b/tests/Tests/_VerifySnapshots/CumulativeSumAggregationUsageTests.VerifyInitializerJson.verified.txt new file mode 100644 index 00000000000..a0e1fc16da9 --- /dev/null +++ b/tests/Tests/_VerifySnapshots/CumulativeSumAggregationUsageTests.VerifyInitializerJson.verified.txt @@ -0,0 +1,30 @@ +{ + aggregations: { + projects_started_per_month: { + aggregations: { + commits: { + sum: { + field: numberOfCommits + } + }, + cumulative_commits: { + cumulative_sum: { + buckets_path: commits + } + } + }, + date_histogram: { + calendar_interval: month, + field: startedOn + } + } + }, + query: { + term: { + type: { + value: project + } + } + }, + size: 0 +} \ No newline at end of file