Skip to content

Commit 01591c5

Browse files
committed
Regenerate documentation
1 parent d62e095 commit 01591c5

18 files changed

+494
-65
lines changed

docs/aggregations.asciidoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ The values are typically extracted from the fields of the document (using the fi
6262

6363
* <<value-count-aggregation-usage,Value Count Aggregation Usage>>
6464

65+
* <<weighted-average-aggregation-usage,Weighted Average Aggregation Usage>>
66+
6567
See the Elasticsearch documentation on {ref_current}/search-aggregations-metrics.html[Metric aggregations] for more details.
6668

6769
:includes-from-dirs: aggregations/metric
@@ -94,6 +96,8 @@ include::aggregations/metric/top-hits/top-hits-aggregation-usage.asciidoc[]
9496

9597
include::aggregations/metric/value-count/value-count-aggregation-usage.asciidoc[]
9698

99+
include::aggregations/metric/weighted-average/weighted-average-aggregation-usage.asciidoc[]
100+
97101
[[bucket-aggregations]]
98102
== Bucket Aggregations
99103

@@ -233,6 +237,8 @@ There are many different types of pipeline aggregation, each computing different
233237

234238
* <<moving-average-simple-aggregation-usage,Moving Average Simple Aggregation Usage>>
235239

240+
* <<moving-function-aggregation-usage,Moving Function Aggregation Usage>>
241+
236242
* <<percentiles-bucket-aggregation-usage,Percentiles Bucket Aggregation Usage>>
237243

238244
* <<serial-differencing-aggregation-usage,Serial Differencing Aggregation Usage>>
@@ -273,6 +279,8 @@ include::aggregations/pipeline/moving-average/moving-average-linear-aggregation-
273279

274280
include::aggregations/pipeline/moving-average/moving-average-simple-aggregation-usage.asciidoc[]
275281

282+
include::aggregations/pipeline/moving-function/moving-function-aggregation-usage.asciidoc[]
283+
276284
include::aggregations/pipeline/percentiles-bucket/percentiles-bucket-aggregation-usage.asciidoc[]
277285

278286
include::aggregations/pipeline/serial-differencing/serial-differencing-aggregation-usage.asciidoc[]

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

Lines changed: 131 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ new CompositeAggregation("my_buckets")
145145

146146
==== Handling Responses
147147

148-
Each Composite aggregation bucket key is an `CompositeKey`, a specialized
148+
Each Composite aggregation bucket key is a `CompositeKey` type, a specialized
149149
`IReadOnlyDictionary<string, object>` type with methods to convert values to supported types
150150

151151
[source,csharp]
@@ -185,3 +185,133 @@ foreach (var item in composite.Buckets)
185185
}
186186
----
187187

188+
[float]
189+
=== Missing buckets
190+
191+
By default documents without a value for a given source are ignored.
192+
It is possible to include them in the response by setting missing_bucket to `true` (defaults to `false`):
193+
194+
NOTE: Only available in Elasticsearch 6.4.0+
195+
196+
==== Fluent DSL example
197+
198+
[source,csharp]
199+
----
200+
a => a
201+
.Composite("my_buckets", date => date
202+
.Sources(s => s
203+
.Terms("branches", t => t
204+
.Field(f => f.Branches.Suffix("keyword"))
205+
.MissingBucket()
206+
.Order(SortOrder.Ascending)
207+
)
208+
)
209+
.Aggregations(childAggs => childAggs
210+
.Nested("project_tags", n => n
211+
.Path(p => p.Tags)
212+
.Aggregations(nestedAggs => nestedAggs
213+
.Terms("tags", avg => avg.Field(p => p.Tags.First().Name))
214+
)
215+
)
216+
)
217+
)
218+
----
219+
220+
==== Object Initializer syntax example
221+
222+
[source,csharp]
223+
----
224+
new CompositeAggregation("my_buckets")
225+
{
226+
Sources = new List<ICompositeAggregationSource>
227+
{
228+
new TermsCompositeAggregationSource("branches")
229+
{
230+
Field = Infer.Field<Project>(f => f.Branches.Suffix("keyword")),
231+
MissingBucket = true,
232+
Order = SortOrder.Ascending
233+
}
234+
},
235+
Aggregations = new NestedAggregation("project_tags")
236+
{
237+
Path = Field<Project>(p => p.Tags),
238+
Aggregations = new TermsAggregation("tags")
239+
{
240+
Field = Field<Project>(p => p.Tags.First().Name)
241+
}
242+
}
243+
}
244+
----
245+
246+
[source,javascript]
247+
.Example json output
248+
----
249+
{
250+
"my_buckets": {
251+
"composite": {
252+
"sources": [
253+
{
254+
"branches": {
255+
"terms": {
256+
"field": "branches.keyword",
257+
"order": "asc",
258+
"missing_bucket": true
259+
}
260+
}
261+
}
262+
]
263+
},
264+
"aggs": {
265+
"project_tags": {
266+
"nested": {
267+
"path": "tags"
268+
},
269+
"aggs": {
270+
"tags": {
271+
"terms": {
272+
"field": "tags.name"
273+
}
274+
}
275+
}
276+
}
277+
}
278+
}
279+
}
280+
----
281+
282+
==== Handling Responses
283+
284+
Each Composite aggregation bucket key is an `CompositeKey`, a specialized
285+
`IReadOnlyDictionary<string, object>` type with methods to convert values to supported types
286+
287+
[source,csharp]
288+
----
289+
response.ShouldBeValid();
290+
291+
var composite = response.Aggregations.Composite("my_buckets");
292+
composite.Should().NotBeNull();
293+
composite.Buckets.Should().NotBeNullOrEmpty();
294+
composite.AfterKey.Should().NotBeNull();
295+
296+
if (TestConfiguration.Instance.InRange(">=6.3.0"))
297+
composite.AfterKey.Should().HaveCount(1).And.ContainKeys("branches");
298+
299+
var i = 0;
300+
foreach (var item in composite.Buckets)
301+
{
302+
var key = item.Key;
303+
key.Should().NotBeNull();
304+
305+
key.TryGetValue("branches", out string branches).Should().BeTrue("expected to find 'branches' in composite bucket");
306+
if (i == 0) branches.Should().BeNull("First key should be null as we expect to have some projects with no branches");
307+
else branches.Should().NotBeNullOrEmpty();
308+
309+
var nested = item.Nested("project_tags");
310+
nested.Should().NotBeNull();
311+
312+
var nestedTerms = nested.Terms("tags");
313+
nestedTerms.Buckets.Count.Should().BeGreaterThan(0);
314+
i++;
315+
}
316+
----
317+

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,12 @@ new DateHistogramAggregation("projects_started_per_month")
114114
}
115115
----
116116

117-
=== Handling responses
117+
==== Handling responses
118118

119119
The `AggregateDictionary found on `.Aggregations` on `ISearchResponse<T>` has several helper methods
120120
so we can fetch our aggregation results easily in the correct type.
121121
<<handling-aggregate-response, Be sure to read more about these helper methods>>
122122

123-
==== Handling Responses
124-
125123
[source,csharp]
126124
----
127125
response.ShouldBeValid();

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,12 @@ new DateRangeAggregation("projects_date_ranges")
9393
}
9494
----
9595

96-
=== Handling Responses
96+
==== Handling Responses
9797

9898
The `AggregateDictionary found on `.Aggregations` on `ISearchResponse<T>` has several helper methods
9999
so we can fetch our aggregation results easily in the correct type.
100100
<<handling-aggregate-response, Be sure to read more about these helper methods>>
101101

102-
==== Handling Responses
103-
104102
[source,csharp]
105103
----
106104
response.ShouldBeValid();

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

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@ new FilterAggregation("bethels_projects")
6868
}
6969
----
7070

71-
=== Handling Responses
71+
==== Handling Responses
7272

7373
The `AggregateDictionary found on `.Aggregations` on `ISearchResponse<T>` has several helper methods
7474
so we can fetch our aggregation results easily in the correct type.
7575
<<handling-aggregate-response, Be sure to read more about these helper methods>>
7676

77-
==== Handling Responses
78-
7977
[source,csharp]
8078
----
8179
response.ShouldBeValid();
@@ -89,7 +87,7 @@ tags.Buckets.Should().NotBeEmpty();
8987
----
9088

9189
[float]
92-
== Empty Filter
90+
=== Empty Filter
9391

9492
When the collection of filters is empty or all are conditionless, NEST will serialize them
9593
to an empty object.
@@ -138,54 +136,3 @@ new FilterAggregation("empty_filter")
138136
response.ShouldNotBeValid();
139137
----
140138

141-
==== Fluent DSL example
142-
143-
[source,csharp]
144-
----
145-
a => a
146-
.Filter(_aggName, date => date
147-
.Filter(f => f
148-
.Script(b => b
149-
.Source(_ctxNumberofCommits)
150-
)
151-
)
152-
)
153-
----
154-
155-
==== Object Initializer syntax example
156-
157-
[source,csharp]
158-
----
159-
new FilterAggregation(_aggName)
160-
{
161-
Filter = new ScriptQuery
162-
{
163-
Source = _ctxNumberofCommits
164-
}
165-
}
166-
----
167-
168-
[source,javascript]
169-
.Example json output
170-
----
171-
{
172-
"script_filter": {
173-
"filter": {
174-
"script": {
175-
"script": {
176-
"source": "_source.numberOfCommits > 0"
177-
}
178-
}
179-
}
180-
}
181-
}
182-
----
183-
184-
==== Handling Responses
185-
186-
[source,csharp]
187-
----
188-
response.ShouldBeValid();
189-
response.Aggregations.Filter(_aggName).DocCount.Should().BeGreaterThan(0);
190-
----
191-

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ ipRanges.Should().NotBeNull();
7474
ipRanges.Buckets.Should().NotBeNull();
7575
ipRanges.Buckets.Count.Should().BeGreaterThan(0);
7676
foreach (var range in ipRanges.Buckets)
77+
{
78+
if (TestConfiguration.Instance.InRange("6.4.0"))
79+
range.Key.Should().NotBeNullOrEmpty();
80+
7781
range.DocCount.Should().BeGreaterThan(0);
82+
}
7883
----
7984

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/6.3
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/Aggregations/Metric/WeightedAverage/WeightedAverageAggregationUsageTests.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+
[[weighted-average-aggregation-usage]]
16+
=== Weighted Average Aggregation Usage
17+
18+
A single-value metrics aggregation that computes the weighted average of numeric values that are extracted
19+
from the aggregated documents. These values can be extracted either from specific numeric fields in the documents.
20+
When calculating a regular average, each datapoint has an equal "weight" i.e. it contributes equally to the final
21+
value. Weighted averages, on the other hand, weight each datapoint differently. The amount that each
22+
datapoint contributes to the final value is extracted from the document, or provided by a script.
23+
24+
Be sure to read the Elasticsearch documentation on {ref_current}/search-aggregations-metrics-weight-avg-aggregation.html[Weighted Avg Aggregation]
25+
26+
==== Fluent DSL example
27+
28+
[source,csharp]
29+
----
30+
a => a
31+
.WeightedAverage("weighted_avg_commits", avg => avg
32+
.Value(v => v.Field(p => p.NumberOfCommits).Missing(0))
33+
.Weight(w => w.Script("doc.numberOfContributors.value + 1"))
34+
.ValueType(ValueType.Long)
35+
)
36+
----
37+
38+
==== Object Initializer syntax example
39+
40+
[source,csharp]
41+
----
42+
new WeightedAverageAggregation("weighted_avg_commits")
43+
{
44+
Value = new WeightedAverageValue(Field<Project>(p => p.NumberOfCommits))
45+
{
46+
Missing = 0
47+
},
48+
Weight = new WeightedAverageValue(new InlineScript("doc.numberOfContributors.value + 1")),
49+
ValueType = ValueType.Long
50+
}
51+
----
52+
53+
[source,javascript]
54+
.Example json output
55+
----
56+
{
57+
"weighted_avg_commits": {
58+
"weighted_avg": {
59+
"value": {
60+
"field": "numberOfCommits",
61+
"missing": 0.0
62+
},
63+
"weight": {
64+
"script": {
65+
"source": "doc.numberOfContributors.value + 1"
66+
}
67+
},
68+
"value_type": "long"
69+
}
70+
}
71+
}
72+
----
73+
74+
==== Handling Responses
75+
76+
[source,csharp]
77+
----
78+
response.ShouldBeValid();
79+
var commitsAvg = response.Aggregations.WeightedAverage("weighted_avg_commits");
80+
commitsAvg.Should().NotBeNull();
81+
commitsAvg.Value.Should().BeGreaterThan(0);
82+
----
83+

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ projectsPerMonth.Should().NotBeNull();
9898
projectsPerMonth.Buckets.Should().NotBeNull();
9999
projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0);
100100
101-
// average not calculated for the first bucket
101+
// average not calculated for the first bucket so movingAvg.Value is expected to be null there
102102
foreach(var item in projectsPerMonth.Buckets.Skip(1))
103103
{
104104
var movingAvg = item.Sum("commits_moving_avg");

0 commit comments

Comments
 (0)