You are looking at documentation for an older release.
Not what you want? See the
current release documentation.
Global Aggregation Usageedit
Fluent DSL Exampleedit
s => s
.Aggregations(a => a
.Global("all_projects", g => g
.Aggregations(aa => aa
.Terms("names", t => t
.Field(p => p.Name)
)
)
)
)Object Initializer Syntax Exampleedit
new SearchRequest<Project>
{
Aggregations = new GlobalAggregation("all_projects")
{
Aggregations = new TermsAggregation("names")
{
Field = Field<Project>(p => p.Name)
}
}
}Example json output.
{
"aggs": {
"all_projects": {
"global": {},
"aggs": {
"names": {
"terms": {
"field": "name"
}
}
}
}
}
}
Handling Responsesedit
response.ShouldBeValid();
var allProjects = response.Aggs.Global("all_projects");
allProjects.Should().NotBeNull();
var names = allProjects.Terms("names");
names.Should().NotBeNull();