Skip to content

Commit 980c428

Browse files
Add shortcut properties for HistogramOrder (#6379) (#6380)
Co-authored-by: Steve Gordon <sgordon@hotmail.co.uk>
1 parent 3cb84ee commit 980c428

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace Elastic.Clients.Elasticsearch.Aggregations;
6+
7+
public partial class HistogramOrder
8+
{
9+
public static HistogramOrder KeyDescending => new() { Key = SortOrder.Desc };
10+
11+
public static HistogramOrder KeyAscending => new() { Key = SortOrder.Asc };
12+
13+
public static HistogramOrder CountDescending => new() { Count = SortOrder.Desc };
14+
15+
public static HistogramOrder CountAscending => new() { Count = SortOrder.Asc };
16+
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information.
44

5-
namespace Elastic.Clients.Elasticsearch.Aggregations
5+
namespace Elastic.Clients.Elasticsearch.Aggregations;
6+
7+
public class TermsBucket<TKey> : TermsBucketBase
68
{
7-
public class TermsBucket<TKey> : TermsBucketBase
8-
{
9-
public TKey Key { get; init; }
10-
public string? KeyAsString { get; init; }
11-
}
9+
public TKey Key { get; init; }
10+
public string? KeyAsString { get; init; }
1211
}

src/Playground/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@
6565
.DateHistogram("by-month", dh => dh
6666
.CalendarInterval(CalendarInterval.Month)
6767
.Field(fld => fld.Date)
68-
//.Order(HistogramOrder.KeyDescending)
69-
.Order(new HistogramOrder { Key = SortOrder.Desc })
68+
.Order(HistogramOrder.KeyDescending)
7069
.Aggregations(agg => agg
7170
.Sum("trade-volumes", sum => sum.Field(fld => fld.Volume))))));
7271

v7

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)