Skip to content

Commit ddad9f3

Browse files
Support cumulative sum aggregation. (#7437) (#7438)
* Update to latest spec version and regen * Support buckets_path on pipeline aggs * Add tests * Update aggregation tests * Fix converter Co-authored-by: Steve Gordon <[email protected]>
1 parent 5de9787 commit ddad9f3

File tree

59 files changed

+1999
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1999
-113
lines changed

src/Elastic.Clients.Elasticsearch/Types/Aggregations/AggregateDictionaryConverter.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,14 @@ public static void ReadAggregate(ref Utf8JsonReader reader, JsonSerializerOption
407407
break;
408408
}
409409

410-
case "cumulative_sum":
411-
throw new Exception("The aggregate in response is not yet supported.");
410+
// Used by:
411+
// - cumulative sum aggregation
412+
case "simple_value":
413+
{
414+
var agg = JsonSerializer.Deserialize<SimpleValueAggregate>(ref reader, options);
415+
dictionary.Add(nameParts[1], agg);
416+
break;
417+
}
412418

413419
case "derivative":
414420
{

src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs

+38-13
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ public sealed class FieldCapsRequestParameters : RequestParameters
4141
/// </summary>
4242
public ICollection<Elastic.Clients.Elasticsearch.ExpandWildcard>? ExpandWildcards { get => Q<ICollection<Elastic.Clients.Elasticsearch.ExpandWildcard>?>("expand_wildcards"); set => Q("expand_wildcards", value); }
4343

44-
/// <summary>
45-
/// <para>Comma-separated list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.</para>
46-
/// </summary>
47-
public Elastic.Clients.Elasticsearch.Fields? Fields { get => Q<Elastic.Clients.Elasticsearch.Fields?>("fields"); set => Q("fields", value); }
48-
4944
/// <summary>
5045
/// <para>If `true`, missing or closed indices are not included in the response.</para>
5146
/// </summary>
@@ -98,12 +93,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r
9893
[JsonIgnore]
9994
public ICollection<Elastic.Clients.Elasticsearch.ExpandWildcard>? ExpandWildcards { get => Q<ICollection<Elastic.Clients.Elasticsearch.ExpandWildcard>?>("expand_wildcards"); set => Q("expand_wildcards", value); }
10095

101-
/// <summary>
102-
/// <para>Comma-separated list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.</para>
103-
/// </summary>
104-
[JsonIgnore]
105-
public Elastic.Clients.Elasticsearch.Fields? Fields { get => Q<Elastic.Clients.Elasticsearch.Fields?>("fields"); set => Q("fields", value); }
106-
10796
/// <summary>
10897
/// <para>If `true`, missing or closed indices are not included in the response.</para>
10998
/// </summary>
@@ -128,6 +117,12 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r
128117
[JsonIgnore]
129118
public ICollection<string>? Types { get => Q<ICollection<string>?>("types"); set => Q("types", value); }
130119

120+
/// <summary>
121+
/// <para>List of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.</para>
122+
/// </summary>
123+
[JsonInclude, JsonPropertyName("fields")]
124+
public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; }
125+
131126
/// <summary>
132127
/// <para>Allows to filter indices if the provided query rewrites to match_none on every shard.</para>
133128
/// </summary>
@@ -160,7 +155,6 @@ public FieldCapsRequestDescriptor()
160155

161156
public FieldCapsRequestDescriptor<TDocument> AllowNoIndices(bool? allowNoIndices = true) => Qs("allow_no_indices", allowNoIndices);
162157
public FieldCapsRequestDescriptor<TDocument> ExpandWildcards(ICollection<Elastic.Clients.Elasticsearch.ExpandWildcard>? expandWildcards) => Qs("expand_wildcards", expandWildcards);
163-
public FieldCapsRequestDescriptor<TDocument> Fields(Elastic.Clients.Elasticsearch.Fields? fields) => Qs("fields", fields);
164158
public FieldCapsRequestDescriptor<TDocument> Filters(string? filters) => Qs("filters", filters);
165159
public FieldCapsRequestDescriptor<TDocument> IgnoreUnavailable(bool? ignoreUnavailable = true) => Qs("ignore_unavailable", ignoreUnavailable);
166160
public FieldCapsRequestDescriptor<TDocument> IncludeUnmapped(bool? includeUnmapped = true) => Qs("include_unmapped", includeUnmapped);
@@ -175,6 +169,7 @@ public FieldCapsRequestDescriptor<TDocument> Indices(Elastic.Clients.Elasticsear
175169
private Elastic.Clients.Elasticsearch.QueryDsl.Query? IndexFilterValue { get; set; }
176170
private QueryDsl.QueryDescriptor<TDocument> IndexFilterDescriptor { get; set; }
177171
private Action<QueryDsl.QueryDescriptor<TDocument>> IndexFilterDescriptorAction { get; set; }
172+
private Elastic.Clients.Elasticsearch.Fields? FieldsValue { get; set; }
178173
private IDictionary<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.Mapping.RuntimeField>? RuntimeMappingsValue { get; set; }
179174

180175
/// <summary>
@@ -204,6 +199,15 @@ public FieldCapsRequestDescriptor<TDocument> IndexFilter(Action<QueryDsl.QueryDe
204199
return Self;
205200
}
206201

202+
/// <summary>
203+
/// <para>List of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.</para>
204+
/// </summary>
205+
public FieldCapsRequestDescriptor<TDocument> Fields(Elastic.Clients.Elasticsearch.Fields? fields)
206+
{
207+
FieldsValue = fields;
208+
return Self;
209+
}
210+
207211
/// <summary>
208212
/// <para>Defines ad-hoc runtime fields in the request similar to the way it is done in search requests.<br/>These fields exist only as part of the query and take precedence over fields defined with the same name in the index mappings.</para>
209213
/// </summary>
@@ -232,6 +236,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
232236
JsonSerializer.Serialize(writer, IndexFilterValue, options);
233237
}
234238

239+
if (FieldsValue is not null)
240+
{
241+
writer.WritePropertyName("fields");
242+
JsonSerializer.Serialize(writer, FieldsValue, options);
243+
}
244+
235245
if (RuntimeMappingsValue is not null)
236246
{
237247
writer.WritePropertyName("runtime_mappings");
@@ -261,7 +271,6 @@ public FieldCapsRequestDescriptor()
261271

262272
public FieldCapsRequestDescriptor AllowNoIndices(bool? allowNoIndices = true) => Qs("allow_no_indices", allowNoIndices);
263273
public FieldCapsRequestDescriptor ExpandWildcards(ICollection<Elastic.Clients.Elasticsearch.ExpandWildcard>? expandWildcards) => Qs("expand_wildcards", expandWildcards);
264-
public FieldCapsRequestDescriptor Fields(Elastic.Clients.Elasticsearch.Fields? fields) => Qs("fields", fields);
265274
public FieldCapsRequestDescriptor Filters(string? filters) => Qs("filters", filters);
266275
public FieldCapsRequestDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Qs("ignore_unavailable", ignoreUnavailable);
267276
public FieldCapsRequestDescriptor IncludeUnmapped(bool? includeUnmapped = true) => Qs("include_unmapped", includeUnmapped);
@@ -276,6 +285,7 @@ public FieldCapsRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices?
276285
private Elastic.Clients.Elasticsearch.QueryDsl.Query? IndexFilterValue { get; set; }
277286
private QueryDsl.QueryDescriptor IndexFilterDescriptor { get; set; }
278287
private Action<QueryDsl.QueryDescriptor> IndexFilterDescriptorAction { get; set; }
288+
private Elastic.Clients.Elasticsearch.Fields? FieldsValue { get; set; }
279289
private IDictionary<Elastic.Clients.Elasticsearch.Field, Elastic.Clients.Elasticsearch.Mapping.RuntimeField>? RuntimeMappingsValue { get; set; }
280290

281291
/// <summary>
@@ -305,6 +315,15 @@ public FieldCapsRequestDescriptor IndexFilter(Action<QueryDsl.QueryDescriptor> c
305315
return Self;
306316
}
307317

318+
/// <summary>
319+
/// <para>List of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.</para>
320+
/// </summary>
321+
public FieldCapsRequestDescriptor Fields(Elastic.Clients.Elasticsearch.Fields? fields)
322+
{
323+
FieldsValue = fields;
324+
return Self;
325+
}
326+
308327
/// <summary>
309328
/// <para>Defines ad-hoc runtime fields in the request similar to the way it is done in search requests.<br/>These fields exist only as part of the query and take precedence over fields defined with the same name in the index mappings.</para>
310329
/// </summary>
@@ -333,6 +352,12 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
333352
JsonSerializer.Serialize(writer, IndexFilterValue, options);
334353
}
335354

355+
if (FieldsValue is not null)
356+
{
357+
writer.WritePropertyName("fields");
358+
JsonSerializer.Serialize(writer, FieldsValue, options);
359+
}
360+
336361
if (RuntimeMappingsValue is not null)
337362
{
338363
writer.WritePropertyName("runtime_mappings");

src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs

+61-9
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public override SearchRequest Read(ref Utf8JsonReader reader, Type typeToConvert
245245

246246
if (property == "knn")
247247
{
248-
variant.Knn = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.KnnQuery?>(ref reader, options);
248+
variant.Knn = JsonSerializer.Deserialize<ICollection<Elastic.Clients.Elasticsearch.KnnQuery>?>(ref reader, options);
249249
continue;
250250
}
251251

@@ -824,8 +824,8 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r =>
824824
/// <summary>
825825
/// <para>Defines the approximate kNN search to run.</para>
826826
/// </summary>
827-
[JsonInclude, JsonPropertyName("knn")]
828-
public Elastic.Clients.Elasticsearch.KnnQuery? Knn { get; set; }
827+
[JsonInclude, JsonPropertyName("knn"), SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.KnnQuery))]
828+
public ICollection<Elastic.Clients.Elasticsearch.KnnQuery>? Knn { get; set; }
829829

830830
/// <summary>
831831
/// <para>Minimum _score for matching documents. Documents with a lower _score are<br/>not included in the search results.</para>
@@ -1016,9 +1016,10 @@ public SearchRequestDescriptor<TDocument> Indices(Elastic.Clients.Elasticsearch.
10161016
private Elastic.Clients.Elasticsearch.Core.Search.Highlight? HighlightValue { get; set; }
10171017
private Core.Search.HighlightDescriptor<TDocument> HighlightDescriptor { get; set; }
10181018
private Action<Core.Search.HighlightDescriptor<TDocument>> HighlightDescriptorAction { get; set; }
1019-
private Elastic.Clients.Elasticsearch.KnnQuery? KnnValue { get; set; }
1019+
private ICollection<Elastic.Clients.Elasticsearch.KnnQuery>? KnnValue { get; set; }
10201020
private KnnQueryDescriptor<TDocument> KnnDescriptor { get; set; }
10211021
private Action<KnnQueryDescriptor<TDocument>> KnnDescriptorAction { get; set; }
1022+
private Action<KnnQueryDescriptor<TDocument>>[] KnnDescriptorActions { get; set; }
10221023
private Elastic.Clients.Elasticsearch.QueryDsl.Query? PostFilterValue { get; set; }
10231024
private QueryDsl.QueryDescriptor<TDocument> PostFilterDescriptor { get; set; }
10241025
private Action<QueryDsl.QueryDescriptor<TDocument>> PostFilterDescriptorAction { get; set; }
@@ -1215,10 +1216,11 @@ public SearchRequestDescriptor<TDocument> Highlight(Action<Core.Search.Highlight
12151216
/// <summary>
12161217
/// <para>Defines the approximate kNN search to run.</para>
12171218
/// </summary>
1218-
public SearchRequestDescriptor<TDocument> Knn(Elastic.Clients.Elasticsearch.KnnQuery? knn)
1219+
public SearchRequestDescriptor<TDocument> Knn(ICollection<Elastic.Clients.Elasticsearch.KnnQuery>? knn)
12191220
{
12201221
KnnDescriptor = null;
12211222
KnnDescriptorAction = null;
1223+
KnnDescriptorActions = null;
12221224
KnnValue = knn;
12231225
return Self;
12241226
}
@@ -1227,6 +1229,7 @@ public SearchRequestDescriptor<TDocument> Knn(KnnQueryDescriptor<TDocument> desc
12271229
{
12281230
KnnValue = null;
12291231
KnnDescriptorAction = null;
1232+
KnnDescriptorActions = null;
12301233
KnnDescriptor = descriptor;
12311234
return Self;
12321235
}
@@ -1235,10 +1238,20 @@ public SearchRequestDescriptor<TDocument> Knn(Action<KnnQueryDescriptor<TDocumen
12351238
{
12361239
KnnValue = null;
12371240
KnnDescriptor = null;
1241+
KnnDescriptorActions = null;
12381242
KnnDescriptorAction = configure;
12391243
return Self;
12401244
}
12411245

1246+
public SearchRequestDescriptor<TDocument> Knn(params Action<KnnQueryDescriptor<TDocument>>[] configure)
1247+
{
1248+
KnnValue = null;
1249+
KnnDescriptor = null;
1250+
KnnDescriptorAction = null;
1251+
KnnDescriptorActions = configure;
1252+
return Self;
1253+
}
1254+
12421255
public SearchRequestDescriptor<TDocument> PostFilter(Elastic.Clients.Elasticsearch.QueryDsl.Query? postFilter)
12431256
{
12441257
PostFilterDescriptor = null;
@@ -1725,10 +1738,23 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
17251738
writer.WritePropertyName("knn");
17261739
JsonSerializer.Serialize(writer, new KnnQueryDescriptor<TDocument>(KnnDescriptorAction), options);
17271740
}
1741+
else if (KnnDescriptorActions is not null)
1742+
{
1743+
writer.WritePropertyName("knn");
1744+
if (KnnDescriptorActions.Length > 1)
1745+
writer.WriteStartArray();
1746+
foreach (var action in KnnDescriptorActions)
1747+
{
1748+
JsonSerializer.Serialize(writer, new KnnQueryDescriptor<TDocument>(action), options);
1749+
}
1750+
1751+
if (KnnDescriptorActions.Length > 1)
1752+
writer.WriteEndArray();
1753+
}
17281754
else if (KnnValue is not null)
17291755
{
17301756
writer.WritePropertyName("knn");
1731-
JsonSerializer.Serialize(writer, KnnValue, options);
1757+
SingleOrManySerializationHelper.Serialize<Elastic.Clients.Elasticsearch.KnnQuery>(KnnValue, writer, options);
17321758
}
17331759

17341760
if (PostFilterDescriptor is not null)
@@ -2061,9 +2087,10 @@ public SearchRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? in
20612087
private Elastic.Clients.Elasticsearch.Core.Search.Highlight? HighlightValue { get; set; }
20622088
private Core.Search.HighlightDescriptor HighlightDescriptor { get; set; }
20632089
private Action<Core.Search.HighlightDescriptor> HighlightDescriptorAction { get; set; }
2064-
private Elastic.Clients.Elasticsearch.KnnQuery? KnnValue { get; set; }
2090+
private ICollection<Elastic.Clients.Elasticsearch.KnnQuery>? KnnValue { get; set; }
20652091
private KnnQueryDescriptor KnnDescriptor { get; set; }
20662092
private Action<KnnQueryDescriptor> KnnDescriptorAction { get; set; }
2093+
private Action<KnnQueryDescriptor>[] KnnDescriptorActions { get; set; }
20672094
private Elastic.Clients.Elasticsearch.QueryDsl.Query? PostFilterValue { get; set; }
20682095
private QueryDsl.QueryDescriptor PostFilterDescriptor { get; set; }
20692096
private Action<QueryDsl.QueryDescriptor> PostFilterDescriptorAction { get; set; }
@@ -2260,10 +2287,11 @@ public SearchRequestDescriptor Highlight(Action<Core.Search.HighlightDescriptor>
22602287
/// <summary>
22612288
/// <para>Defines the approximate kNN search to run.</para>
22622289
/// </summary>
2263-
public SearchRequestDescriptor Knn(Elastic.Clients.Elasticsearch.KnnQuery? knn)
2290+
public SearchRequestDescriptor Knn(ICollection<Elastic.Clients.Elasticsearch.KnnQuery>? knn)
22642291
{
22652292
KnnDescriptor = null;
22662293
KnnDescriptorAction = null;
2294+
KnnDescriptorActions = null;
22672295
KnnValue = knn;
22682296
return Self;
22692297
}
@@ -2272,6 +2300,7 @@ public SearchRequestDescriptor Knn(KnnQueryDescriptor descriptor)
22722300
{
22732301
KnnValue = null;
22742302
KnnDescriptorAction = null;
2303+
KnnDescriptorActions = null;
22752304
KnnDescriptor = descriptor;
22762305
return Self;
22772306
}
@@ -2280,10 +2309,20 @@ public SearchRequestDescriptor Knn(Action<KnnQueryDescriptor> configure)
22802309
{
22812310
KnnValue = null;
22822311
KnnDescriptor = null;
2312+
KnnDescriptorActions = null;
22832313
KnnDescriptorAction = configure;
22842314
return Self;
22852315
}
22862316

2317+
public SearchRequestDescriptor Knn(params Action<KnnQueryDescriptor>[] configure)
2318+
{
2319+
KnnValue = null;
2320+
KnnDescriptor = null;
2321+
KnnDescriptorAction = null;
2322+
KnnDescriptorActions = configure;
2323+
return Self;
2324+
}
2325+
22872326
public SearchRequestDescriptor PostFilter(Elastic.Clients.Elasticsearch.QueryDsl.Query? postFilter)
22882327
{
22892328
PostFilterDescriptor = null;
@@ -2770,10 +2809,23 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o
27702809
writer.WritePropertyName("knn");
27712810
JsonSerializer.Serialize(writer, new KnnQueryDescriptor(KnnDescriptorAction), options);
27722811
}
2812+
else if (KnnDescriptorActions is not null)
2813+
{
2814+
writer.WritePropertyName("knn");
2815+
if (KnnDescriptorActions.Length > 1)
2816+
writer.WriteStartArray();
2817+
foreach (var action in KnnDescriptorActions)
2818+
{
2819+
JsonSerializer.Serialize(writer, new KnnQueryDescriptor(action), options);
2820+
}
2821+
2822+
if (KnnDescriptorActions.Length > 1)
2823+
writer.WriteEndArray();
2824+
}
27732825
else if (KnnValue is not null)
27742826
{
27752827
writer.WritePropertyName("knn");
2776-
JsonSerializer.Serialize(writer, KnnValue, options);
2828+
SingleOrManySerializationHelper.Serialize<Elastic.Clients.Elasticsearch.KnnQuery>(KnnValue, writer, options);
27772829
}
27782830

27792831
if (PostFilterDescriptor is not null)

src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryRequest.g.cs

+10
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public sealed partial class QueryRequest : PlainRequest<QueryRequestParameters>
4949
/// </summary>
5050
[JsonInclude, JsonPropertyName("catalog")]
5151
public string? Catalog { get; set; }
52+
53+
/// <summary>
54+
/// <para>If true, the results in a columnar fashion: one row represents all the values of a certain column from the current page of results.</para>
55+
/// </summary>
5256
[JsonInclude, JsonPropertyName("columnar")]
5357
public bool? Columnar { get; set; }
5458
[JsonInclude, JsonPropertyName("cursor")]
@@ -205,6 +209,9 @@ public QueryRequestDescriptor<TDocument> Catalog(string? catalog)
205209
return Self;
206210
}
207211

212+
/// <summary>
213+
/// <para>If true, the results in a columnar fashion: one row represents all the values of a certain column from the current page of results.</para>
214+
/// </summary>
208215
public QueryRequestDescriptor<TDocument> Columnar(bool? columnar = true)
209216
{
210217
ColumnarValue = columnar;
@@ -510,6 +517,9 @@ public QueryRequestDescriptor Catalog(string? catalog)
510517
return Self;
511518
}
512519

520+
/// <summary>
521+
/// <para>If true, the results in a columnar fashion: one row represents all the values of a certain column from the current page of results.</para>
522+
/// </summary>
513523
public QueryRequestDescriptor Columnar(bool? columnar = true)
514524
{
515525
ColumnarValue = columnar;

0 commit comments

Comments
 (0)