Skip to content

Commit 8d5f78b

Browse files
committed
[Docs] Update aggs sections and include OIS example for each
1 parent a4a9333 commit 8d5f78b

28 files changed

+896
-264
lines changed

Diff for: docs/contents/nest/aggregations/avg.markdown

+34-10
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,41 @@ menuitem: avg
88

99
# Avg aggregation
1010

11-
## Description
12-
13-
A single-value metrics aggregation that computes the average of numeric values that are extracted from the aggregated documents. For more info, read the [docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html).
11+
A single-value metrics aggregation that computes the average of numeric values that are extracted from the aggregated documents.
1412

1513
## Usage
1614

17-
var result = client.Search<ElasticsearchProject>(s => s
18-
.Aggregations(a => a
19-
.Average("avg_aggregation", avg => avg
20-
.Field("followers.age"))));
21-
22-
You can then access the result.Aggregations to get the data, i.e.
15+
### Fluent Syntax
2316

24-
var agg = result.Aggs.Average("avg_aggregation");
17+
var result = client.Search<ElasticsearchProject>(s => s
18+
.Aggregations(a => a
19+
.Average("my_avg_agg", avg => avg
20+
.Field(p => p.Followers.First().Age)
21+
)
22+
)
23+
);
24+
25+
var agg = result.Aggs.Avg("my_avg_agg");
26+
27+
### Object Initializer Syntax
28+
29+
var request = new SearchRequest
30+
{
31+
Aggregations = new Dictionary<string, IAggregationContainer>
32+
{
33+
{ "my_avg_agg", new AggregationContainer
34+
{
35+
Terms = new TermsAggregator
36+
{
37+
Field = "followers.age"
38+
}
39+
}
40+
}
41+
}
42+
};
43+
44+
var result = client.Search<ElasticsearchProject>(request);
45+
46+
var agg = result.Aggs.Avg("my_avg_agg");
47+
48+
Refer to the [original docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html) for more information.

Diff for: docs/contents/nest/aggregations/cardinality.markdown

+34-10
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,41 @@ menuitem: cardinality
88

99
# Cardinality aggregation
1010

11-
## Description
12-
13-
A single-value metrics aggregation that calculates an approximate count of distinct values. For more info, read the [docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html).
11+
A single-value metrics aggregation that calculates an approximate count of distinct values.
1412

1513
## Usage
1614

17-
var result = client.Search<ElasticsearchProject>(s => s
18-
.Aggregations(a => a
19-
.Cardinality("cardinality_aggregation", cardinality => cardinality
20-
.Field("followers.firstName"))));
21-
22-
You can then access the result.Aggregations to get the data, i.e.
15+
### Fluent Syntax
2316

24-
var agg = result.Aggs.Cardinality("cardinality_aggregation");
17+
var result = client.Search<ElasticsearchProject>(s => s
18+
.Aggregations(a => a
19+
.Cardinality("my_cardinality_agg", c => c
20+
.Field(p => p.Followers.First().FirstName)
21+
)
22+
)
23+
);
24+
25+
var agg = result.Aggs.Cardinality("my_cardinality_agg");
26+
27+
### Object Initializer Syntax
28+
29+
var request = new SearchRequest
30+
{
31+
Aggregations = new Dictionary<string, IAggregationContainer>
32+
{
33+
{ "my_cardinality_agg", new AggregationContainer
34+
{
35+
Cardinality = new CardinalityAggregator
36+
{
37+
Field = "followers.firstName"
38+
}
39+
}
40+
}
41+
}
42+
};
43+
44+
var result = client.Search<ElasticsearchProject>(request);
45+
46+
var agg = result.Aggs.Cardinality("my_cardinality_agg");
47+
48+
Refer to the [original docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html) for more information.

Diff for: docs/contents/nest/aggregations/date-histogram.markdown

+36-11
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,43 @@ menuitem: date-histogram
88

99
# Date Histogram aggregation
1010

11-
## Description
12-
13-
A multi-bucket aggregation similar to the histogram except it can only be applied on date values. For more info, read the [docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html).
11+
A multi-bucket aggregation similar to the histogram except it can only be applied on date values.
1412

1513
## Usage
1614

17-
var result = _client.Search<ElasticsearchProject>(s => s
18-
.Aggregations(a => a
19-
.DateHistogram("date_histogram", h => h
20-
.Field("startedOn")
21-
.Interval("month"))));
22-
23-
You can then access the result.Aggregations to get the data, i.e.
15+
### Fluent Syntax
2416

25-
var rangeAgg = result.Aggs.DateHistogram("date_histogram");
17+
var result = _client.Search<ElasticsearchProject>(s => s
18+
.Aggregations(a => a
19+
.DateHistogram("my_date_histogram", h => h
20+
.Field(p => p.StartedOn)
21+
.Interval("month")
22+
)
23+
)
24+
);
25+
26+
var agg = result.Aggs.DateHistogram("my_date_histogram");
27+
28+
### Object Initializer Syntax
29+
30+
var request = new SearchRequest
31+
{
32+
Aggregations = new Dictionary<string, IAggregationContainer>
33+
{
34+
{ "my_date_histogram", new AggregationContainer
35+
{
36+
DateHistogram = new DateHistogramAggregator
37+
{
38+
Field = "startedOn",
39+
Interval = "month"
40+
}
41+
}
42+
}
43+
}
44+
};
45+
46+
var result = client.Search<ElasticsearchProject>(request);
47+
48+
var agg = result.Aggs.DateHistogram("my_date_histogram");
49+
50+
Refer to the [original docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html) for more information.

Diff for: docs/contents/nest/aggregations/date-range.markdown

+46-16
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,52 @@ menuitem: date-range
88

99
# Date Range aggregation
1010

11-
## Description
12-
13-
A range aggregation that is dedicated for date values. For more info, read the [docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html).
11+
A range aggregation that is dedicated for date values.
1412

1513
## Usage
1614

17-
var result = _client.Search<ElasticsearchProject>(s => s
18-
.Aggregations(a => a
19-
.DateRange("date_range", date => date
20-
.Field("startedOn")
21-
.Format("MM-yyy")
22-
.Ranges(
23-
r => r.To("now-10M/M"),
24-
r => r.From("now-10M/M")
25-
))));
26-
27-
You can then access the result.Aggregations to get the data, i.e.
28-
29-
var rangeAgg = result.Aggs.DateRange("date_range");
15+
### Fluent Syntax
16+
17+
var result = client.Search<ElasticsearchProject>(s => s
18+
.Aggregations(a => a
19+
.DateRange("my_date_range_agg", d => d
20+
.Field(p => p.StartedOn)
21+
.Format("MM-yyy")
22+
.Ranges(
23+
r => r.To("now-10M/M"),
24+
r => r.From("now-10M/M")
25+
)
26+
)
27+
)
28+
);
29+
30+
var agg = result.Aggs.DateRange("my_date_range_agg");
31+
32+
### Object Initializer Syntax
33+
34+
var request = new SearchRequest
35+
{
36+
Aggregations = new Dictionary<string, IAggregationContainer>
37+
{
38+
{ "my_date_range_agg", new AggregationContainer
39+
{
40+
DateRange = new DateRangeAggregator
41+
{
42+
Field = "startedOn",
43+
Format = "MM-yyy",
44+
Ranges = new List<DateExpressionRange>
45+
{
46+
new DateExpressionRange().To("now-10M/M"),
47+
new DateExpressionRange().From("now-10M/M")
48+
}
49+
}
50+
}
51+
}
52+
}
53+
};
54+
55+
var result = client.Search<ElasticsearchProject>(request);
56+
57+
var agg = result.Aggs.DateRange("my_date_range_agg");
58+
59+
Refer to the [original docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html) for more information.

Diff for: docs/contents/nest/aggregations/extended-stats.markdown

+34-10
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,41 @@ menuitem: extended-stats
88

99
# Extended Stats aggregation
1010

11-
## Description
12-
13-
A multi-value metrics aggregation that computes stats over numeric values extracted from the aggregated documents. For more info, read the [docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html).
11+
A multi-value metrics aggregation that computes stats over numeric values extracted from the aggregated documents.
1412

1513
## Usage
1614

17-
var result = client.Search<ElasticsearchProject>(s => s
18-
.Aggregations(a => a
19-
.ExtendedStats("extendedstats_aggregation", stats => stats
20-
.Field("followers.age"))));
21-
22-
You can then access the result.Aggregations to get the data, i.e.
15+
### Fluent Syntax
2316

24-
var agg = result.Aggs.ExtendedStats("extendedstats_aggregation");
17+
var result = client.Search<ElasticsearchProject>(s => s
18+
.Aggregations(a => a
19+
.ExtendedStats("my_extendedstats_agg", stats => stats
20+
.Field(p => p.Followers.First().Age)
21+
)
22+
)
23+
);
24+
25+
var agg = result.Aggs.ExtendedStats("my_extendedstats_agg");
26+
27+
### Object Initializer Syntax
28+
29+
var request = new SearchRequest
30+
{
31+
Aggregations = new Dictionary<string, IAggregationContainer>
32+
{
33+
{ "my_extendedstats_agg", new AggregationContainer
34+
{
35+
ExtendedStats = new ExtendedStatsAggregator
36+
{
37+
Field = "followers.age"
38+
}
39+
}
40+
}
41+
}
42+
};
43+
44+
var result = client.Search<ElasticsearchProject>(request);
45+
46+
var agg = result.Aggs.ExtendedStats("my_extendedstats_agg");
47+
48+
Refer to the [original docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html) for more information.

Diff for: docs/contents/nest/aggregations/filter.markdown

+62-18
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,68 @@ menuitem: filter
88

99
# Filter aggregation
1010

11-
## Description
12-
13-
Defines a single bucket of all the documents in the current document set context that match a specified filter. For more info, read the [docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html).
11+
Defines a single bucket of all the documents in the current document set context that match a specified filter.
1412

1513
## Usage
1614

17-
var result = _client.Search<ElasticsearchProject>(s => s
18-
.Aggregations(a => a
19-
.Filter("filter_agg", f => f
20-
.Filter(fd => fd
21-
.Range(r => r
22-
.Greater(12000)
23-
.OnField(data => data.LOC)))
24-
.Aggregations(agg => agg
25-
.Average("avg_agg", avg => avg
26-
.Field(data => data.LOC))))));
27-
28-
You can then access the result.Aggregations to get the data, i.e.
29-
30-
var filterAgg = result.Aggs.Filter("filter_agg");
31-
var avgAgg = filterAgg.Average("avg_agg");
15+
### Fluent Syntax
16+
17+
var result = client.Search<ElasticsearchProject>(s => s
18+
.Aggregations(a => a
19+
.Filter("my_filter_agg", f => f
20+
.Filter(fd => fd
21+
.Range(r => r
22+
.Greater(12000)
23+
.OnField(p => p.LOC)
24+
)
25+
)
26+
.Aggregations(agg => agg
27+
.Average("my_avg_agg", avg => avg
28+
.Field(p => p.LOC)
29+
)
30+
)
31+
)
32+
)
33+
);
34+
35+
var filterAgg = result.Aggs.Filter("my_filter_agg");
36+
var avgAgg = filterAgg.Average("my_avg_agg");
37+
38+
### Object Initializer Syntax
39+
40+
var request = new SearchRequest
41+
{
42+
Aggregations = new Dictionary<string, IAggregationContainer>
43+
{
44+
{ "my_filter_agg", new AggregationContainer
45+
{
46+
Filter = new FilterAggregator
47+
{
48+
Filter = new FilterContainer(new RangeFilter
49+
{
50+
Field = "loc",
51+
GreaterThan = "12000"
52+
})
53+
},
54+
Aggregations = new Dictionary<string, IAggregationContainer>
55+
{
56+
{ "my_avg_agg", new AggregationContainer
57+
{
58+
Average = new AverageAggregator
59+
{
60+
Field = "loc"
61+
}
62+
}
63+
}
64+
}
65+
}
66+
}
67+
}
68+
};
69+
70+
var result = client.Search<ElasticsearchProject>(request);
71+
72+
var filterAgg = result.Aggs.Filter("my_filter_agg");
73+
var avgAgg = filterAgg.Average("my_avg_agg");
74+
75+
Refer to the [original docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html) for more information.

Diff for: docs/contents/nest/aggregations/geo-bounds.markdown

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ menuitem: geo-bounds
88

99
# Geo Bounds aggregation
1010

11-
Not available until ElasticSearch 1.3
11+
A metric aggregation that computes the bounding box containing all geo_point values for a field.
12+
13+
*Not implemented yet*
14+
15+
Refer to the [original docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geobounds-aggregation.html#search-aggregations-metrics-geobounds-aggregation) for more information.

0 commit comments

Comments
 (0)