Skip to content

Commit 2234d5b

Browse files
committed
6.5.0 release
1 parent 3f4c703 commit 2234d5b

File tree

98 files changed

+779
-679
lines changed

Some content is hidden

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

98 files changed

+779
-679
lines changed

docs/aggregations.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ In addition to the buckets themselves, the bucket aggregations also compute and
110110

111111
* <<adjacency-matrix-usage,Adjacency Matrix Usage>>
112112

113+
* <<auto-date-histogram-aggregation-usage,Auto Date Histogram Aggregation Usage>>
114+
113115
* <<children-aggregation-usage,Children Aggregation Usage>>
114116

115117
* <<composite-aggregation-usage,Composite Aggregation Usage>>
@@ -163,6 +165,8 @@ See the Elasticsearch documentation on {ref_current}/search-aggregations-bucket.
163165

164166
include::aggregations/bucket/adjacency-matrix/adjacency-matrix-usage.asciidoc[]
165167

168+
include::aggregations/bucket/auto-date-histogram/auto-date-histogram-aggregation-usage.asciidoc[]
169+
166170
include::aggregations/bucket/children/children-aggregation-usage.asciidoc[]
167171

168172
include::aggregations/bucket/composite/composite-aggregation-usage.asciidoc[]

docs/aggregations/aggregation-meta-usage.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ a => a
3838
----
3939
new MinAggregation("min_last_activity", Infer.Field<Project>(p => p.LastActivity))
4040
{
41-
Meta = new Dictionary<string,object>
41+
Meta = new Dictionary<string, object>
4242
{
4343
{ "meta_1", "value_1" },
4444
{ "meta_2", 2 },

docs/aggregations/bucket/adjacency-matrix/adjacency-matrix-usage.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ new AdjacencyMatrixAggregation("interactions")
3737
{
3838
Filters = new NamedFiltersContainer
3939
{
40-
{"grpA", new TermQuery {Field = "state", Value = StateOfBeing.BellyUp}},
41-
{"grpB", new TermQuery {Field = "state", Value = StateOfBeing.Stable}},
42-
{"grpC", new TermQuery {Field = "state", Value = StateOfBeing.VeryActive}},
40+
{ "grpA", new TermQuery { Field = "state", Value = StateOfBeing.BellyUp } },
41+
{ "grpB", new TermQuery { Field = "state", Value = StateOfBeing.Stable } },
42+
{ "grpC", new TermQuery { Field = "state", Value = StateOfBeing.VeryActive } },
4343
}
4444
}
4545
----
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/6.4
2+
3+
:github: https://github.com/elastic/elasticsearch-net
4+
5+
:nuget: https://www.nuget.org/packages
6+
7+
////
8+
IMPORTANT NOTE
9+
==============
10+
This file has been generated from https://github.com/elastic/elasticsearch-net/tree/6.x/src/Tests/Tests/Aggregations/Bucket/AutoDateHistogram/AutoDateHistogramAggregationUsageTests.cs.
11+
If you wish to submit a PR for any spelling mistakes, typos or grammatical errors for this file,
12+
please modify the original csharp file found at the link and submit the PR with that change. Thanks!
13+
////
14+
15+
[[auto-date-histogram-aggregation-usage]]
16+
=== Auto Date Histogram Aggregation Usage
17+
18+
A multi-bucket aggregation similar to the Date Histogram Aggregation except instead of providing an interval to
19+
use as the width of each bucket, a target number of buckets is provided indicating the number of buckets needed
20+
and the interval of the buckets is automatically chosen to best achieve that target. The number of buckets
21+
returned will always be less than or equal to this target number.
22+
23+
NOTE: When specifying a `format` **and** `extended_bounds` or `missing`, in order for Elasticsearch to be able to parse
24+
the serialized `DateTime` of `extended_bounds` or `missing` correctly, the `date_optional_time` format is included
25+
as part of the `format` value.
26+
27+
Be sure to read the Elasticsearch documentation on {ref_current}/search-aggregations-bucket-autodatehistogram-aggregation.html[Auto Date Histogram Aggregation].
28+
29+
==== Fluent DSL example
30+
31+
[source,csharp]
32+
----
33+
a => a
34+
.AutoDateHistogram("projects_started_per_month", date => date
35+
.Field(p => p.StartedOn)
36+
.Format("yyyy-MM-dd'T'HH:mm:ss")
37+
.Missing(FixedDate)
38+
.Aggregations(childAggs => childAggs
39+
.Nested("project_tags", n => n
40+
.Path(p => p.Tags)
41+
.Aggregations(nestedAggs => nestedAggs
42+
.Terms("tags", avg => avg.Field(p => p.Tags.First().Name))
43+
)
44+
)
45+
)
46+
)
47+
----
48+
49+
==== Object Initializer syntax example
50+
51+
[source,csharp]
52+
----
53+
new AutoDateHistogramAggregation("projects_started_per_month")
54+
{
55+
Field = Field<Project>(p => p.StartedOn),
56+
Format = "yyyy-MM-dd'T'HH:mm:ss",
57+
Missing = FixedDate,
58+
Aggregations = new NestedAggregation("project_tags")
59+
{
60+
Path = Field<Project>(p => p.Tags),
61+
Aggregations = new TermsAggregation("tags")
62+
{
63+
Field = Field<Project>(p => p.Tags.First().Name)
64+
}
65+
}
66+
}
67+
----
68+
69+
[source,javascript]
70+
.Example json output
71+
----
72+
{
73+
"projects_started_per_month": {
74+
"auto_date_histogram": {
75+
"field": "startedOn",
76+
"format": "yyyy-MM-dd'T'HH:mm:ss||date_optional_time",
77+
"missing": "2015-06-06T12:01:02.123"
78+
},
79+
"aggs": {
80+
"project_tags": {
81+
"nested": {
82+
"path": "tags"
83+
},
84+
"aggs": {
85+
"tags": {
86+
"terms": {
87+
"field": "tags.name"
88+
}
89+
}
90+
}
91+
}
92+
}
93+
}
94+
}
95+
----
96+
97+
==== Handling responses
98+
99+
The `AggregateDictionary found on `.Aggregations` on `ISearchResponse<T>` has several helper methods
100+
so we can fetch our aggregation results easily in the correct type.
101+
<<handling-aggregate-response, Be sure to read more about these helper methods>>
102+
103+
[source,csharp]
104+
----
105+
response.ShouldBeValid();
106+
107+
var dateHistogram = response.Aggregations.AutoDateHistogram("projects_started_per_month");
108+
dateHistogram.Should().NotBeNull();
109+
dateHistogram.Interval.Should().NotBeNull();
110+
dateHistogram.Buckets.Should().NotBeNull();
111+
dateHistogram.Buckets.Count.Should().BeGreaterThan(1);
112+
foreach (var item in dateHistogram.Buckets)
113+
{
114+
item.Date.Should().NotBe(default);
115+
item.DocCount.Should().BeGreaterThan(0);
116+
117+
var nested = item.Nested("project_tags");
118+
nested.Should().NotBeNull();
119+
120+
var nestedTerms = nested.Terms("tags");
121+
nestedTerms.Buckets.Count.Should().BeGreaterThan(0);
122+
}
123+
----
124+

docs/aggregations/bucket/composite/composite-aggregation-usage.asciidoc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ new CompositeAggregation("my_buckets")
6969
{
7070
new TermsCompositeAggregationSource("branches")
7171
{
72-
Field = Infer.Field<Project>(f => f.Branches.Suffix("keyword"))
72+
Field = Field<Project>(f => f.Branches.Suffix("keyword"))
7373
},
7474
new DateHistogramCompositeAggregationSource("started")
7575
{
76-
Field = Infer.Field<Project>(f => f.StartedOn),
76+
Field = Field<Project>(f => f.StartedOn),
7777
Interval = DateInterval.Month
7878
},
7979
new HistogramCompositeAggregationSource("branch_count")
8080
{
81-
Field = Infer.Field<Project>(f => f.RequiredBranches),
81+
Field = Field<Project>(f => f.RequiredBranches),
8282
Interval = 1
8383
}
8484
},
@@ -157,10 +157,9 @@ composite.Should().NotBeNull();
157157
composite.Buckets.Should().NotBeNullOrEmpty();
158158
composite.AfterKey.Should().NotBeNull();
159159
if (TestConfiguration.Instance.InRange(">=6.3.0"))
160-
{
161-
composite.AfterKey.Should().HaveCount(3)
160+
composite.AfterKey.Should()
161+
.HaveCount(3)
162162
.And.ContainKeys("branches", "started", "branch_count");
163-
}
164163
foreach (var item in composite.Buckets)
165164
{
166165
var key = item.Key;
@@ -230,7 +229,7 @@ new CompositeAggregation("my_buckets")
230229
{
231230
new TermsCompositeAggregationSource("branches")
232231
{
233-
Field = Infer.Field<Project>(f => f.Branches.Suffix("keyword")),
232+
Field = Field<Project>(f => f.Branches.Suffix("keyword")),
234233
MissingBucket = true,
235234
Order = SortOrder.Ascending
236235
}

docs/aggregations/bucket/date-range/date-range-aggregation-usage.asciidoc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ new DateRangeAggregation("projects_date_ranges")
5151
Field = Field<Project>(p => p.StartedOn),
5252
Ranges = new List<DateRangeExpression>
5353
{
54-
new DateRangeExpression {From = DateMath.Anchored(FixedDate).Add("2d"), To = DateMath.Now},
55-
new DateRangeExpression {To = DateMath.Now.Add(TimeSpan.FromDays(1)).Subtract("30m").RoundTo(DateMathTimeUnit.Hour)},
56-
new DateRangeExpression {From = DateMath.Anchored("2012-05-05").Add(TimeSpan.FromDays(1)).Subtract("1m")}
54+
new DateRangeExpression { From = DateMath.Anchored(FixedDate).Add("2d"), To = DateMath.Now },
55+
new DateRangeExpression { To = DateMath.Now.Add(TimeSpan.FromDays(1)).Subtract("30m").RoundTo(DateMathTimeUnit.Hour) },
56+
new DateRangeExpression { From = DateMath.Anchored("2012-05-05").Add(TimeSpan.FromDays(1)).Subtract("1m") }
5757
},
5858
TimeZone = "CET",
5959
Aggregations =
60-
new TermsAggregation("project_tags") {Field = Field<Project>(p => p.Tags)}
60+
new TermsAggregation("project_tags") { Field = Field<Project>(p => p.Tags) }
6161
}
6262
----
6363

@@ -113,9 +113,6 @@ We specified three ranges so we expect to have three of them in the response
113113
[source,csharp]
114114
----
115115
dateHistogram.Buckets.Count.Should().Be(3);
116-
foreach (var item in dateHistogram.Buckets)
117-
{
118-
item.DocCount.Should().BeGreaterThan(0);
119-
}
116+
foreach (var item in dateHistogram.Buckets) item.DocCount.Should().BeGreaterThan(0);
120117
----
121118

docs/aggregations/bucket/filter/filter-aggregation-usage.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ a => a
3939
----
4040
new FilterAggregation("bethels_projects")
4141
{
42-
Filter = new TermQuery {Field = Field<Project>(p => p.LeadDeveloper.FirstName), Value = FirstNameToFind},
42+
Filter = new TermQuery { Field = Field<Project>(p => p.LeadDeveloper.FirstName), Value = FirstNameToFind },
4343
Aggregations =
44-
new TermsAggregation("project_tags") {Field = Field<Project>(p => p.CuratedTags.First().Name.Suffix("keyword"))}
44+
new TermsAggregation("project_tags") { Field = Field<Project>(p => p.CuratedTags.First().Name.Suffix("keyword")) }
4545
}
4646
----
4747

@@ -133,6 +133,6 @@ new FilterAggregation("empty_filter")
133133

134134
[source,csharp]
135135
----
136-
response.ShouldNotBeValid();
136+
response.ShouldNotBeValid()
137137
----
138138

docs/aggregations/bucket/filters/filters-aggregation-usage.asciidoc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ new FiltersAggregation("projects_by_state")
5353
OtherBucketKey = "other_states_of_being",
5454
Filters = new NamedFiltersContainer
5555
{
56-
{"belly_up", Query<Project>.Term(p => p.State, StateOfBeing.BellyUp)},
57-
{"stable", Query<Project>.Term(p => p.State, StateOfBeing.Stable)},
58-
{"very_active", Query<Project>.Term(p => p.State, StateOfBeing.VeryActive)}
56+
{ "belly_up", Query<Project>.Term(p => p.State, StateOfBeing.BellyUp) },
57+
{ "stable", Query<Project>.Term(p => p.State, StateOfBeing.Stable) },
58+
{ "very_active", Query<Project>.Term(p => p.State, StateOfBeing.VeryActive) }
5959
},
6060
Aggregations =
61-
new TermsAggregation("project_tags") {Field = Field<Project>(p => p.CuratedTags.First().Name.Suffix("keyword"))}
61+
new TermsAggregation("project_tags") { Field = Field<Project>(p => p.CuratedTags.First().Name.Suffix("keyword")) }
6262
}
6363
----
6464

@@ -170,7 +170,7 @@ new FiltersAggregation("projects_by_state")
170170
Query<Project>.Term(p => p.State, StateOfBeing.VeryActive)
171171
},
172172
Aggregations =
173-
new TermsAggregation("project_tags") {Field = Field<Project>(p => p.CuratedTags.First().Name.Suffix("keyword"))}
173+
new TermsAggregation("project_tags") { Field = Field<Project>(p => p.CuratedTags.First().Name.Suffix("keyword")) }
174174
}
175175
----
176176

@@ -231,10 +231,7 @@ filterAgg.Should().NotBeNull();
231231
var results = filterAgg.AnonymousBuckets();
232232
results.Count.Should().Be(4);
233233
234-
foreach (var singleBucket in results.Take(3))
235-
{
236-
singleBucket.DocCount.Should().BeGreaterThan(0);
237-
}
234+
foreach (var singleBucket in results.Take(3)) singleBucket.DocCount.Should().BeGreaterThan(0);
238235
239236
results.Last().DocCount.Should().Be(0); <1>
240237
----

docs/aggregations/bucket/geo-distance/geo-distance-aggregation-usage.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ new GeoDistanceAggregation("rings_around_amsterdam")
4141
Origin = "52.376, 4.894",
4242
Ranges = new List<AggregationRange>
4343
{
44-
new AggregationRange {To = 100},
45-
new AggregationRange {From = 100, To = 300},
46-
new AggregationRange {From = 300}
44+
new AggregationRange { To = 100 },
45+
new AggregationRange { From = 100, To = 300 },
46+
new AggregationRange { From = 300 }
4747
}
4848
}
4949
----

docs/aggregations/bucket/ip-range/ip-range-aggregation-usage.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ new IpRangeAggregation("ip_ranges")
3838
Field = Field((Project p) => p.LeadDeveloper.IpAddress),
3939
Ranges = new List<Nest.IpRange>
4040
{
41-
new Nest.IpRange {To = "127.0.0.1"},
42-
new Nest.IpRange {From = "127.0.0.1"}
41+
new Nest.IpRange { To = "127.0.0.1" },
42+
new Nest.IpRange { From = "127.0.0.1" }
4343
}
4444
}
4545
----

docs/aggregations/bucket/nested/nested-aggregation-usage.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ var tags = response.Aggregations.Nested("tags");
7272
tags.Should().NotBeNull();
7373
var tagNames = tags.Terms("tag_names");
7474
tagNames.Should().NotBeNull();
75-
foreach(var item in tagNames.Buckets)
75+
foreach (var item in tagNames.Buckets)
7676
{
7777
item.Key.Should().NotBeNullOrEmpty();
7878
item.DocCount.Should().BeGreaterThan(0);

docs/aggregations/bucket/range/range-aggregation-usage.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ new RangeAggregation("commit_ranges")
3939
Field = Field<Project>(p => p.NumberOfCommits),
4040
Ranges = new List<AggregationRange>
4141
{
42-
{new AggregationRange {To = 100}},
43-
{new AggregationRange {From = 100, To = 500}},
44-
{new AggregationRange {From = 500}}
42+
{ new AggregationRange { To = 100 } },
43+
{ new AggregationRange { From = 100, To = 500 } },
44+
{ new AggregationRange { From = 500 } }
4545
}
4646
}
4747
----

docs/aggregations/bucket/reverse-nested/reverse-nested-aggregation-usage.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ var tags = response.Aggregations.Nested("tags");
100100
tags.Should().NotBeNull();
101101
var tagNames = tags.Terms("tag_names");
102102
tagNames.Should().NotBeNull();
103-
foreach(var tagName in tagNames.Buckets)
103+
foreach (var tagName in tagNames.Buckets)
104104
{
105105
tagName.Key.Should().NotBeNullOrEmpty();
106106
tagName.DocCount.Should().BeGreaterThan(0);
107107
var tagsToProjects = tagName.ReverseNested("tags_to_project");
108108
tagsToProjects.Should().NotBeNull();
109109
var topProjectsPerTag = tagsToProjects.Terms("top_projects_per_tag");
110110
topProjectsPerTag.Should().NotBeNull();
111-
foreach(var topProject in topProjectsPerTag.Buckets)
111+
foreach (var topProject in topProjectsPerTag.Buckets)
112112
{
113113
topProject.Key.Should().NotBeNullOrEmpty();
114114
topProject.DocCount.Should().BeGreaterThan(0);

docs/aggregations/bucket/significant-terms/significant-terms-aggregation-usage.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ a => a
170170
.BackgroundIsSuperSet()
171171
.IncludeNegatives()
172172
)
173-
.Exclude(new[] {"pierce"})
173+
.Exclude(new[] { "pierce" })
174174
)
175175
----
176176

@@ -187,7 +187,7 @@ new SignificantTermsAggregation("significant_names")
187187
BackgroundIsSuperSet = true,
188188
IncludeNegatives = true
189189
},
190-
Exclude = new SignificantTermsIncludeExclude(new[] {"pierce"})
190+
Exclude = new SignificantTermsIncludeExclude(new[] { "pierce" })
191191
}
192192
----
193193

0 commit comments

Comments
 (0)