Skip to content

Commit 7d3044b

Browse files
committed
Add search usage to docs
Visit foreach statements when generating source code documentation Add ability to hide code with preceding //hide comment Tidy up existing docs
1 parent 30166f6 commit 7d3044b

File tree

71 files changed

+1007
-745
lines changed

Some content is hidden

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

71 files changed

+1007
-745
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,17 @@ var dateHistogram = response.Aggs.DateHistogram("projects_started_per_month");
129129
dateHistogram.Should().NotBeNull();
130130
dateHistogram.Buckets.Should().NotBeNull();
131131
dateHistogram.Buckets.Count.Should().BeGreaterThan(10);
132-
item.Date.Should().NotBe(default(DateTime));
133-
item.DocCount.Should().BeGreaterThan(0);
134-
var nested = item.Nested("project_tags");
135-
nested.Should().NotBeNull();
136-
var nestedTerms = nested.Terms("tags");
137-
nestedTerms.Buckets.Count.Should().BeGreaterThan(0);
132+
133+
foreach (var item in dateHistogram.Buckets)
134+
{
135+
item.Date.Should().NotBe(default(DateTime));
136+
item.DocCount.Should().BeGreaterThan(0);
137+
138+
var nested = item.Nested("project_tags");
139+
nested.Should().NotBeNull();
140+
141+
var nestedTerms = nested.Terms("tags");
142+
nestedTerms.Buckets.Count.Should().BeGreaterThan(0);
143+
}
138144
----
139145

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ dateHistogram.Buckets.Should().NotBeNull();
105105

106106
We specified three ranges so we expect to have three of them in the response
107107

108-
=== Handling Responses
109-
110108
[source,csharp]
111109
----
112110
dateHistogram.Buckets.Count.Should().Be(3);
113111
114-
item.DocCount.Should().BeGreaterThan(0);
112+
foreach (var item in dateHistogram.Buckets)
113+
{
114+
item.DocCount.Should().BeGreaterThan(0);
115+
}
115116
----
116117

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,12 @@ var filterAgg = response.Aggs.Filters("projects_by_state");
235235
filterAgg.Should().NotBeNull();
236236
var results = filterAgg.AnonymousBuckets();
237237
results.Count.Should().Be(4);
238-
singleBucket.DocCount.Should().BeGreaterThan(0);
238+
239+
foreach (var singleBucket in results.Take(3))
240+
{
241+
singleBucket.DocCount.Should().BeGreaterThan(0);
242+
}
243+
239244
results.Last().DocCount.Should().Be(0); <1>
240245
----
241246
<1> The last bucket is the _other bucket_

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ new SearchRequest<Project>
6464
response.IsValid.Should().BeTrue();
6565
var commits = response.Aggs.Histogram("commits");
6666
commits.Should().NotBeNull();
67-
item.DocCount.Should().BeGreaterThan(0);
67+
68+
foreach (var item in commits.Buckets)
69+
item.DocCount.Should().BeGreaterThan(0);
6870
----
6971

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ var ipRanges = response.Aggs.IpRange("ip_ranges");
7272
ipRanges.Should().NotBeNull();
7373
ipRanges.Buckets.Should().NotBeNull();
7474
ipRanges.Buckets.Count.Should().BeGreaterThan(0);
75-
range.DocCount.Should().BeGreaterThan(0);
75+
76+
foreach (var range in ipRanges.Buckets)
77+
range.DocCount.Should().BeGreaterThan(0);
7678
----
7779

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ var tags = response.Aggs.Nested("tags");
7171
tags.Should().NotBeNull();
7272
var tagNames = tags.Terms("tag_names");
7373
tagNames.Should().NotBeNull();
74-
item.Key.Should().NotBeNullOrEmpty();
75-
item.DocCount.Should().BeGreaterThan(0);
74+
75+
foreach(var item in tagNames.Buckets)
76+
{
77+
item.Key.Should().NotBeNullOrEmpty();
78+
item.DocCount.Should().BeGreaterThan(0);
79+
}
7680
----
7781

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,20 @@ var tags = response.Aggs.Nested("tags");
9999
tags.Should().NotBeNull();
100100
var tagNames = tags.Terms("tag_names");
101101
tagNames.Should().NotBeNull();
102-
tagName.Key.Should().NotBeNullOrEmpty();
103-
tagName.DocCount.Should().BeGreaterThan(0);
104-
var tagsToProjects = tagName.ReverseNested("tags_to_project");
105-
tagsToProjects.Should().NotBeNull();
106-
var topProjectsPerTag = tagsToProjects.Terms("top_projects_per_tag");
107-
topProjectsPerTag.Should().NotBeNull();
108-
topProject.Key.Should().NotBeNullOrEmpty();
109-
topProject.DocCount.Should().BeGreaterThan(0);
102+
103+
foreach(var tagName in tagNames.Buckets)
104+
{
105+
tagName.Key.Should().NotBeNullOrEmpty();
106+
tagName.DocCount.Should().BeGreaterThan(0);
107+
var tagsToProjects = tagName.ReverseNested("tags_to_project");
108+
tagsToProjects.Should().NotBeNull();
109+
var topProjectsPerTag = tagsToProjects.Terms("top_projects_per_tag");
110+
topProjectsPerTag.Should().NotBeNull();
111+
foreach(var topProject in topProjectsPerTag.Buckets)
112+
{
113+
topProject.Key.Should().NotBeNullOrEmpty();
114+
topProject.DocCount.Should().BeGreaterThan(0);
115+
}
116+
}
110117
----
111118

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@ var states = response.Aggs.Terms("states");
103103
states.Should().NotBeNull();
104104
states.DocCountErrorUpperBound.Should().HaveValue();
105105
states.SumOtherDocCount.Should().HaveValue();
106-
item.Key.Should().NotBeNullOrEmpty();
107-
item.DocCount.Should().BeGreaterOrEqualTo(1);
106+
107+
foreach (var item in states.Buckets)
108+
{
109+
item.Key.Should().NotBeNullOrEmpty();
110+
item.DocCount.Should().BeGreaterOrEqualTo(1);
111+
}
112+
108113
states.Meta.Should().NotBeNull().And.HaveCount(1);
109114
states.Meta["foo"].Should().Be("bar");
110115
----

docs/asciidoc/aggregations/metric/percentile-ranks/percentile-ranks-aggregation-usage.asciidoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ response.IsValid.Should().BeTrue();
7979
var commitsOutlier = response.Aggs.PercentileRanks("commits_outlier");
8080
commitsOutlier.Should().NotBeNull();
8181
commitsOutlier.Items.Should().NotBeNullOrEmpty();
82-
item.Should().NotBeNull();
82+
83+
foreach (var item in commitsOutlier.Items)
84+
item.Should().NotBeNull();
8385
----
8486

docs/asciidoc/aggregations/metric/percentiles/percentiles-aggregation-usage.asciidoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ response.IsValid.Should().BeTrue();
8080
var commitsOutlier = response.Aggs.Percentiles("commits_outlier");
8181
commitsOutlier.Should().NotBeNull();
8282
commitsOutlier.Items.Should().NotBeNullOrEmpty();
83-
item.Value.Should().BeGreaterThan(0);
83+
84+
foreach (var item in commitsOutlier.Items)
85+
item.Value.Should().BeGreaterThan(0);
8486
----
8587

docs/asciidoc/aggregations/metric/top-hits/top-hits-aggregation-usage.asciidoc

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,23 @@ response.IsValid.Should().BeTrue();
154154
var states = response.Aggs.Terms("states");
155155
states.Should().NotBeNull();
156156
states.Buckets.Should().NotBeNullOrEmpty();
157-
state.Key.Should().NotBeNullOrEmpty();
158-
state.DocCount.Should().BeGreaterThan(0);
159-
var topStateHits = state.TopHits("top_state_hits");
160-
topStateHits.Should().NotBeNull();
161-
topStateHits.Total.Should().BeGreaterThan(0);
162-
var hits = topStateHits.Hits<Project>();
163-
hits.Should().NotBeNullOrEmpty();
164-
hits.All(h => h.Explanation != null).Should().BeTrue();
165-
hits.All(h => h.Version.HasValue).Should().BeTrue();
166-
hits.All(h => h.Fields.ValuesOf<StateOfBeing>("state").Any()).Should().BeTrue();
167-
hits.All(h => h.Fields.ValuesOf<int>("numberOfCommits").Any()).Should().BeTrue();
168-
hits.All(h => h.Fields.ValuesOf<int>("commit_factor").Any()).Should().BeTrue();
169-
topStateHits.Documents<Project>().Should().NotBeEmpty();
157+
158+
foreach(var state in states.Buckets)
159+
{
160+
state.Key.Should().NotBeNullOrEmpty();
161+
state.DocCount.Should().BeGreaterThan(0);
162+
var topStateHits = state.TopHits("top_state_hits");
163+
topStateHits.Should().NotBeNull();
164+
topStateHits.Total.Should().BeGreaterThan(0);
165+
var hits = topStateHits.Hits<Project>();
166+
hits.Should().NotBeNullOrEmpty();
167+
hits.All(h => h.Explanation != null).Should().BeTrue();
168+
hits.All(h => h.Version.HasValue).Should().BeTrue();
169+
//hits.All(h => h.Highlights.Count() > 0).Should().BeTrue();
170+
hits.All(h => h.Fields.ValuesOf<StateOfBeing>("state").Any()).Should().BeTrue();
171+
hits.All(h => h.Fields.ValuesOf<int>("numberOfCommits").Any()).Should().BeTrue();
172+
hits.All(h => h.Fields.ValuesOf<int>("commit_factor").Any()).Should().BeTrue();
173+
topStateHits.Documents<Project>().Should().NotBeEmpty();
174+
}
170175
----
171176

docs/asciidoc/aggregations/pipeline/bucket-script/bucket-script-aggregation-usage.asciidoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month")
136136
projectsPerMonth.Should().NotBeNull();
137137
projectsPerMonth.Buckets.Should().NotBeNull();
138138
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
139-
var stablePercentage = item.BucketScript("stable_percentage");
140-
stablePercentage.Should().NotBeNull();
141-
stablePercentage.Value.Should().HaveValue();
139+
140+
foreach(var item in projectsPerMonth.Buckets)
141+
{
142+
var stablePercentage = item.BucketScript("stable_percentage");
143+
stablePercentage.Should().NotBeNull();
144+
stablePercentage.Value.Should().HaveValue();
145+
}
142146
----
143147

docs/asciidoc/aggregations/pipeline/bucket-selector/bucket-selector-aggregation-usage.asciidoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month")
9898
projectsPerMonth.Should().NotBeNull();
9999
projectsPerMonth.Buckets.Should().NotBeNull();
100100
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
101-
var commits = item.Sum("commits");
102-
commits.Should().NotBeNull();
103-
commits.Value.Should().BeGreaterOrEqualTo(500);
101+
102+
foreach(var item in projectsPerMonth.Buckets)
103+
{
104+
var commits = item.Sum("commits");
105+
commits.Should().NotBeNull();
106+
commits.Value.Should().BeGreaterOrEqualTo(500);
107+
}
104108
----
105109

docs/asciidoc/aggregations/pipeline/cumulative-sum/cumulative-sum-aggregation-usage.asciidoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month")
1616
projectsPerMonth.Should().NotBeNull();
1717
projectsPerMonth.Buckets.Should().NotBeNull();
1818
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
19-
var commitsDerivative = item.Derivative("cumulative_commits");
20-
commitsDerivative.Should().NotBeNull();
21-
commitsDerivative.Value.Should().NotBe(null);
19+
20+
foreach (var item in projectsPerMonth.Buckets)
21+
{
22+
var commitsDerivative = item.Derivative("cumulative_commits");
23+
commitsDerivative.Should().NotBeNull();
24+
commitsDerivative.Value.Should().NotBe(null);
25+
}
2226
----
2327

2428
=== Fluent DSL Example

docs/asciidoc/aggregations/pipeline/derivative/derivative-aggregation-usage.asciidoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month")
1616
projectsPerMonth.Should().NotBeNull();
1717
projectsPerMonth.Buckets.Should().NotBeNull();
1818
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
19-
var commitsDerivative = item.Derivative("commits_derivative");
20-
commitsDerivative.Should().NotBeNull();
21-
commitsDerivative.Value.Should().NotBe(null);
19+
20+
foreach (var item in projectsPerMonth.Buckets.Skip(1))
21+
{
22+
var commitsDerivative = item.Derivative("commits_derivative");
23+
commitsDerivative.Should().NotBeNull();
24+
commitsDerivative.Value.Should().NotBe(null);
25+
}
2226
----
2327

2428
=== Fluent DSL Example

docs/asciidoc/aggregations/pipeline/max-bucket/max-bucket-aggregation-usage.asciidoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ maxCommits.Should().NotBeNull();
8888
maxCommits.Value.Should().BeGreaterThan(0);
8989
maxCommits.Keys.Should().NotBeNull();
9090
maxCommits.Keys.Count.Should().BeGreaterOrEqualTo(1);
91-
key.Should().NotBeNull();
91+
92+
foreach (var key in maxCommits.Keys)
93+
key.Should().NotBeNull();
9294
----
9395

docs/asciidoc/aggregations/pipeline/min-bucket/min-bucket-aggregation-usage.asciidoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ minCommits.Should().NotBeNull();
8888
minCommits.Value.Should().BeGreaterThan(0);
8989
minCommits.Keys.Should().NotBeNull();
9090
minCommits.Keys.Count.Should().BeGreaterOrEqualTo(1);
91-
key.Should().NotBeNullOrEmpty();
91+
92+
foreach (var key in minCommits.Keys)
93+
key.Should().NotBeNullOrEmpty();
9294
----
9395

docs/asciidoc/aggregations/pipeline/moving-average/moving-average-ewma-aggregation-usage.asciidoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month")
9999
projectsPerMonth.Should().NotBeNull();
100100
projectsPerMonth.Buckets.Should().NotBeNull();
101101
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
102-
var movingAvg = item.MovingAverage("commits_moving_avg");
103-
movingAvg.Should().NotBeNull();
104-
movingAvg.Value.Should().BeGreaterThan(0);
102+
103+
foreach(var item in projectsPerMonth.Buckets.Skip(1))
104+
{
105+
var movingAvg = item.MovingAverage("commits_moving_avg");
106+
movingAvg.Should().NotBeNull();
107+
movingAvg.Value.Should().BeGreaterThan(0);
108+
}
105109
----
106110

docs/asciidoc/aggregations/pipeline/moving-average/moving-average-holt-linear-aggregation-usage.asciidoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,12 @@ var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month")
102102
projectsPerMonth.Should().NotBeNull();
103103
projectsPerMonth.Buckets.Should().NotBeNull();
104104
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
105-
var movingAvg = item.MovingAverage("commits_moving_avg");
106-
movingAvg.Should().NotBeNull();
107-
movingAvg.Value.Should().BeGreaterThan(0);
105+
106+
foreach(var item in projectsPerMonth.Buckets.Skip(1))
107+
{
108+
var movingAvg = item.MovingAverage("commits_moving_avg");
109+
movingAvg.Should().NotBeNull();
110+
movingAvg.Value.Should().BeGreaterThan(0);
111+
}
108112
----
109113

docs/asciidoc/aggregations/pipeline/moving-average/moving-average-linear-aggregation-usage.asciidoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,12 @@ var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month")
9595
projectsPerMonth.Should().NotBeNull();
9696
projectsPerMonth.Buckets.Should().NotBeNull();
9797
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
98-
var movingAvg = item.MovingAverage("commits_moving_avg");
99-
movingAvg.Should().NotBeNull();
100-
movingAvg.Value.Should().BeGreaterThan(0);
98+
99+
foreach(var item in projectsPerMonth.Buckets.Skip(1))
100+
{
101+
var movingAvg = item.MovingAverage("commits_moving_avg");
102+
movingAvg.Should().NotBeNull();
103+
movingAvg.Value.Should().BeGreaterThan(0);
104+
}
101105
----
102106

docs/asciidoc/aggregations/pipeline/moving-average/moving-average-simple-aggregation-usage.asciidoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month")
9898
projectsPerMonth.Should().NotBeNull();
9999
projectsPerMonth.Buckets.Should().NotBeNull();
100100
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
101-
var movingAvg = item.Sum("commits_moving_avg");
102-
movingAvg.Should().NotBeNull();
103-
movingAvg.Value.Should().BeGreaterThan(0);
101+
102+
foreach(var item in projectsPerMonth.Buckets.Skip(1))
103+
{
104+
var movingAvg = item.Sum("commits_moving_avg");
105+
movingAvg.Should().NotBeNull();
106+
movingAvg.Value.Should().BeGreaterThan(0);
107+
}
104108
----
105109

docs/asciidoc/aggregations/pipeline/serial-differencing/serial-differencing-aggregation-usage.asciidoc

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,6 @@
77
[[serial-differencing-aggregation-usage]]
88
== Serial Differencing Aggregation Usage
99

10-
=== Handling Responses
11-
12-
[source,csharp]
13-
----
14-
response.IsValid.Should().BeTrue();
15-
var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month");
16-
projectsPerMonth.Should().NotBeNull();
17-
projectsPerMonth.Buckets.Should().NotBeNull();
18-
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
19-
var commits = item.Sum("commits");
20-
commits.Should().NotBeNull();
21-
commits.Value.Should().NotBe(null);
22-
----
23-
2410
=== Fluent DSL Example
2511

2612
[source,csharp]
@@ -94,3 +80,21 @@ new SearchRequest<Project>
9480
}
9581
----
9682

83+
=== Handling Responses
84+
85+
[source,csharp]
86+
----
87+
response.IsValid.Should().BeTrue();
88+
var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month");
89+
projectsPerMonth.Should().NotBeNull();
90+
projectsPerMonth.Buckets.Should().NotBeNull();
91+
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
92+
93+
foreach (var item in projectsPerMonth.Buckets)
94+
{
95+
var commits = item.Sum("commits");
96+
commits.Should().NotBeNull();
97+
commits.Value.Should().NotBe(null);
98+
}
99+
----
100+

docs/asciidoc/aggregations/writing-aggregations.asciidoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ This is the json output for each example
2525
The fluent lambda syntax is the most terse way to write aggregations.
2626
It benefits from types that are carried over to sub aggregations
2727

28-
=== Fluent DSL Example
29-
3028
[source,csharp]
3129
----
3230
s => s

0 commit comments

Comments
 (0)