Skip to content

Commit 1d6c173

Browse files
committed
Rename PercentilesBucket directory
Generate docs for percentiles and stats bucket aggregations Include new files to csproj files
1 parent 4a0c65a commit 1d6c173

File tree

9 files changed

+414
-260
lines changed

9 files changed

+414
-260
lines changed

docs/asciidoc/aggregations-usage.asciidoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ include::../../docs/asciidoc/aggregations/pipeline/cumulative-sum/cumulative-sum
7272

7373
include::../../docs/asciidoc/aggregations/pipeline/derivative/derivative-aggregation-usage.asciidoc[]
7474

75+
include::../../docs/asciidoc/aggregations/pipeline/extended-stats-bucket/extended-stats-bucket-aggregation-usage.asciidoc[]
76+
7577
include::../../docs/asciidoc/aggregations/pipeline/max-bucket/max-bucket-aggregation-usage.asciidoc[]
7678

7779
include::../../docs/asciidoc/aggregations/pipeline/min-bucket/min-bucket-aggregation-usage.asciidoc[]
@@ -86,7 +88,11 @@ include::../../docs/asciidoc/aggregations/pipeline/moving-average/moving-average
8688

8789
include::../../docs/asciidoc/aggregations/pipeline/moving-average/moving-average-simple-aggregation-usage.asciidoc[]
8890

91+
include::../../docs/asciidoc/aggregations/pipeline/percentiles-bucket/percentiles-bucket-aggregation-usage.asciidoc[]
92+
8993
include::../../docs/asciidoc/aggregations/pipeline/serial-differencing/serial-differencing-aggregation-usage.asciidoc[]
9094

95+
include::../../docs/asciidoc/aggregations/pipeline/stats-bucket/stats-bucket-aggregation-usage.asciidoc[]
96+
9197
include::../../docs/asciidoc/aggregations/pipeline/sum-bucket/sum-bucket-aggregation-usage.asciidoc[]
9298

docs/asciidoc/aggregations.asciidoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ exposes all of the available Aggregation types
7878

7979
* <<derivative-aggregation-usage,Derivative Aggregation Usage>>
8080

81+
* <<extended-stats-bucket-aggregation-usage,Extended Stats Bucket Aggregation Usage>>
82+
8183
* <<max-bucket-aggregation-usage,Max Bucket Aggregation Usage>>
8284

8385
* <<min-bucket-aggregation-usage,Min Bucket Aggregation Usage>>
@@ -92,8 +94,12 @@ exposes all of the available Aggregation types
9294

9395
* <<moving-average-simple-aggregation-usage,Moving Average Simple Aggregation Usage>>
9496

97+
* <<percentiles-bucket-aggregation-usage,Percentiles Bucket Aggregation Usage>>
98+
9599
* <<serial-differencing-aggregation-usage,Serial Differencing Aggregation Usage>>
96100

101+
* <<stats-bucket-aggregation-usage,Stats Bucket Aggregation Usage>>
102+
97103
* <<sum-bucket-aggregation-usage,Sum Bucket Aggregation Usage>>
98104

99105
--
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/2.3
2+
3+
:github: https://github.com/elastic/elasticsearch-net
4+
5+
:nuget: https://www.nuget.org/packages
6+
7+
[[extended-stats-bucket-aggregation-usage]]
8+
== Extended Stats Bucket Aggregation Usage
9+
10+
=== Fluent DSL Example
11+
12+
[source,csharp]
13+
----
14+
s => s
15+
.Size(0)
16+
.Aggregations(a => a
17+
.DateHistogram("projects_started_per_month", dh => dh
18+
.Field(p => p.StartedOn)
19+
.Interval(DateInterval.Month)
20+
.Aggregations(aa => aa
21+
.Sum("commits", sm => sm
22+
.Field(p => p.NumberOfCommits)
23+
)
24+
)
25+
)
26+
.ExtendedStatsBucket("extended_stats_commits_per_month", aaa => aaa
27+
.BucketsPath("projects_started_per_month>commits")
28+
.Sigma(2)
29+
)
30+
)
31+
----
32+
33+
=== Object Initializer Syntax Example
34+
35+
[source,csharp]
36+
----
37+
new SearchRequest<Project>()
38+
{
39+
Size = 0,
40+
Aggregations = new DateHistogramAggregation("projects_started_per_month")
41+
{
42+
Field = "startedOn",
43+
Interval = DateInterval.Month,
44+
Aggregations = new SumAggregation("commits", "numberOfCommits")
45+
}
46+
&& new ExtendedStatsBucketAggregation("extended_stats_commits_per_month", "projects_started_per_month>commits")
47+
{
48+
Sigma = 2
49+
}
50+
}
51+
----
52+
53+
[source,javascript]
54+
.Example json output
55+
----
56+
{
57+
"size": 0,
58+
"aggs": {
59+
"projects_started_per_month": {
60+
"date_histogram": {
61+
"field": "startedOn",
62+
"interval": "month"
63+
},
64+
"aggs": {
65+
"commits": {
66+
"sum": {
67+
"field": "numberOfCommits"
68+
}
69+
}
70+
}
71+
},
72+
"extended_stats_commits_per_month": {
73+
"extended_stats_bucket": {
74+
"buckets_path": "projects_started_per_month>commits",
75+
"sigma": 2
76+
}
77+
}
78+
}
79+
}
80+
----
81+
82+
=== Handling Responses
83+
84+
[source,csharp]
85+
----
86+
response.IsValid.Should().BeTrue();
87+
var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month");
88+
projectsPerMonth.Should().NotBeNull();
89+
projectsPerMonth.Buckets.Should().NotBeNull();
90+
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
91+
var commitsStats = response.Aggs.ExtendedStatsBucket("extended_stats_commits_per_month");
92+
commitsStats.Should().NotBeNull();
93+
commitsStats.Average.Should().BeGreaterThan(0);
94+
commitsStats.Max.Should().BeGreaterThan(0);
95+
commitsStats.Min.Should().BeGreaterThan(0);
96+
commitsStats.Count.Should().BeGreaterThan(0);
97+
commitsStats.Sum.Should().BeGreaterThan(0);
98+
commitsStats.SumOfSquares.Should().BeGreaterThan(0);
99+
commitsStats.StdDeviation.Should().BeGreaterThan(0);
100+
commitsStats.StdDeviationBounds.Should().NotBeNull();
101+
commitsStats.StdDeviationBounds.Upper.Should().BeGreaterThan(0);
102+
commitsStats.StdDeviationBounds.Lower.Should().NotBe(0);
103+
----
104+
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/2.3
2+
3+
:github: https://github.com/elastic/elasticsearch-net
4+
5+
:nuget: https://www.nuget.org/packages
6+
7+
[[percentiles-bucket-aggregation-usage]]
8+
== Percentiles Bucket Aggregation Usage
9+
10+
=== Fluent DSL Example
11+
12+
[source,csharp]
13+
----
14+
s => s
15+
.Size(0)
16+
.Aggregations(a => a
17+
.DateHistogram("projects_started_per_month", dh => dh
18+
.Field(p => p.StartedOn)
19+
.Interval(DateInterval.Month)
20+
.Aggregations(aa => aa
21+
.Sum("commits", sm => sm
22+
.Field(p => p.NumberOfCommits)
23+
)
24+
)
25+
)
26+
.PercentilesBucket("commits_outlier", aaa => aaa
27+
.BucketsPath("projects_started_per_month>commits")
28+
.Percents(95, 99, 99.9)
29+
)
30+
)
31+
----
32+
33+
=== Object Initializer Syntax Example
34+
35+
[source,csharp]
36+
----
37+
new SearchRequest<Project>()
38+
{
39+
Size = 0,
40+
Aggregations = new DateHistogramAggregation("projects_started_per_month")
41+
{
42+
Field = "startedOn",
43+
Interval = DateInterval.Month,
44+
Aggregations = new SumAggregation("commits", "numberOfCommits")
45+
}
46+
&& new PercentilesBucketAggregation("commits_outlier", "projects_started_per_month>commits")
47+
{
48+
Percents = new[] { 95, 99, 99.9 }
49+
}
50+
}
51+
----
52+
53+
[source,javascript]
54+
.Example json output
55+
----
56+
{
57+
"size": 0,
58+
"aggs": {
59+
"projects_started_per_month": {
60+
"date_histogram": {
61+
"field": "startedOn",
62+
"interval": "month"
63+
},
64+
"aggs": {
65+
"commits": {
66+
"sum": {
67+
"field": "numberOfCommits"
68+
}
69+
}
70+
}
71+
},
72+
"commits_outlier": {
73+
"percentiles_bucket": {
74+
"buckets_path": "projects_started_per_month>commits",
75+
"percents": [
76+
95.0,
77+
99.0,
78+
99.9
79+
]
80+
}
81+
}
82+
}
83+
}
84+
----
85+
86+
=== Handling Responses
87+
88+
[source,csharp]
89+
----
90+
response.IsValid.Should().BeTrue();
91+
var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month");
92+
projectsPerMonth.Should().NotBeNull();
93+
projectsPerMonth.Buckets.Should().NotBeNull();
94+
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
95+
var commitsOutlier = response.Aggs.PercentilesBucket("commits_outlier");
96+
commitsOutlier.Should().NotBeNull();
97+
commitsOutlier.Items.Should().NotBeNullOrEmpty();
98+
99+
foreach (var item in commitsOutlier.Items)
100+
item.Value.Should().BeGreaterThan(0);
101+
----
102+
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/2.3
2+
3+
:github: https://github.com/elastic/elasticsearch-net
4+
5+
:nuget: https://www.nuget.org/packages
6+
7+
[[stats-bucket-aggregation-usage]]
8+
== Stats Bucket Aggregation Usage
9+
10+
=== Fluent DSL Example
11+
12+
[source,csharp]
13+
----
14+
s => s
15+
.Size(0)
16+
.Aggregations(a => a
17+
.DateHistogram("projects_started_per_month", dh => dh
18+
.Field(p => p.StartedOn)
19+
.Interval(DateInterval.Month)
20+
.Aggregations(aa => aa
21+
.Sum("commits", sm => sm
22+
.Field(p => p.NumberOfCommits)
23+
)
24+
)
25+
)
26+
.StatsBucket("stats_commits_per_month", aaa => aaa
27+
.BucketsPath("projects_started_per_month>commits")
28+
)
29+
)
30+
----
31+
32+
=== Object Initializer Syntax Example
33+
34+
[source,csharp]
35+
----
36+
new SearchRequest<Project>()
37+
{
38+
Size = 0,
39+
Aggregations = new DateHistogramAggregation("projects_started_per_month")
40+
{
41+
Field = "startedOn",
42+
Interval = DateInterval.Month,
43+
Aggregations = new SumAggregation("commits", "numberOfCommits")
44+
}
45+
&& new StatsBucketAggregation("stats_commits_per_month", "projects_started_per_month>commits")
46+
}
47+
----
48+
49+
[source,javascript]
50+
.Example json output
51+
----
52+
{
53+
"size": 0,
54+
"aggs": {
55+
"projects_started_per_month": {
56+
"date_histogram": {
57+
"field": "startedOn",
58+
"interval": "month"
59+
},
60+
"aggs": {
61+
"commits": {
62+
"sum": {
63+
"field": "numberOfCommits"
64+
}
65+
}
66+
}
67+
},
68+
"stats_commits_per_month": {
69+
"stats_bucket": {
70+
"buckets_path": "projects_started_per_month>commits"
71+
}
72+
}
73+
}
74+
}
75+
----
76+
77+
=== Handling Responses
78+
79+
[source,csharp]
80+
----
81+
response.IsValid.Should().BeTrue();
82+
var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month");
83+
projectsPerMonth.Should().NotBeNull();
84+
projectsPerMonth.Buckets.Should().NotBeNull();
85+
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
86+
var commitsStats = response.Aggs.StatsBucket("stats_commits_per_month");
87+
commitsStats.Should().NotBeNull();
88+
commitsStats.Average.Should().BeGreaterThan(0);
89+
commitsStats.Max.Should().BeGreaterThan(0);
90+
commitsStats.Min.Should().BeGreaterThan(0);
91+
commitsStats.Count.Should().BeGreaterThan(0);
92+
commitsStats.Sum.Should().BeGreaterThan(0);
93+
----
94+

0 commit comments

Comments
 (0)