From e9941882672c8bfb2da6c33862f851f7ca144c42 Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Tue, 26 Apr 2022 15:27:01 +0100 Subject: [PATCH] Add shortcut properties for HistogramOrder --- .../Types/Aggregations/HistogramOrder.cs | 16 ++++++++++++++++ .../Types/Aggregations/TermsBucket.cs | 11 +++++------ src/Playground/Program.cs | 3 +-- v7 | 1 - 4 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 src/Elastic.Clients.Elasticsearch/Types/Aggregations/HistogramOrder.cs delete mode 160000 v7 diff --git a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/HistogramOrder.cs b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/HistogramOrder.cs new file mode 100644 index 00000000000..0b2e172e4f8 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/HistogramOrder.cs @@ -0,0 +1,16 @@ +// 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. + +namespace Elastic.Clients.Elasticsearch.Aggregations; + +public partial class HistogramOrder +{ + public static HistogramOrder KeyDescending => new() { Key = SortOrder.Desc }; + + public static HistogramOrder KeyAscending => new() { Key = SortOrder.Asc }; + + public static HistogramOrder CountDescending => new() { Count = SortOrder.Desc }; + + public static HistogramOrder CountAscending => new() { Count = SortOrder.Asc }; +} diff --git a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/TermsBucket.cs b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/TermsBucket.cs index 812c8789db7..bc9649133b6 100644 --- a/src/Elastic.Clients.Elasticsearch/Types/Aggregations/TermsBucket.cs +++ b/src/Elastic.Clients.Elasticsearch/Types/Aggregations/TermsBucket.cs @@ -2,11 +2,10 @@ // 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. -namespace Elastic.Clients.Elasticsearch.Aggregations +namespace Elastic.Clients.Elasticsearch.Aggregations; + +public class TermsBucket : TermsBucketBase { - public class TermsBucket : TermsBucketBase - { - public TKey Key { get; init; } - public string? KeyAsString { get; init; } - } + public TKey Key { get; init; } + public string? KeyAsString { get; init; } } diff --git a/src/Playground/Program.cs b/src/Playground/Program.cs index b54b420df08..2ae7495b435 100644 --- a/src/Playground/Program.cs +++ b/src/Playground/Program.cs @@ -65,8 +65,7 @@ .DateHistogram("by-month", dh => dh .CalendarInterval(CalendarInterval.Month) .Field(fld => fld.Date) - //.Order(HistogramOrder.KeyDescending) - .Order(new HistogramOrder { Key = SortOrder.Desc }) + .Order(HistogramOrder.KeyDescending) .Aggregations(agg => agg .Sum("trade-volumes", sum => sum.Field(fld => fld.Volume)))))); diff --git a/v7 b/v7 deleted file mode 160000 index f4dcd1e0711..00000000000 --- a/v7 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f4dcd1e07110746e378757d70686638f08c925d6