@@ -29,6 +29,26 @@ var response = await client
2929----
3030
3131[discrete]
32+ ==== Object initializer API
33+
34+ [source,csharp]
35+ ----
36+ var response = await client.SearchAsync<Person>(new SearchRequest("persons")
37+ {
38+ Query = Query.MatchAll(new MatchAllQuery()),
39+ Aggregations = new Dictionary<string, Aggregation>
40+ {
41+ { "agg_name", Aggregation.Max(new MaxAggregation
42+ {
43+ Field = Infer.Field<Person>(x => x.Age)
44+ })}
45+ },
46+ Size = 10
47+ });
48+ ----
49+
50+ [discrete]
51+ ==== Consuming the Response
3252==== Consume the response
3353
3454[source,csharp]
@@ -70,6 +90,36 @@ var response = await client
7090----
7191
7292[discrete]
93+ ==== Object initializer API
94+
95+ [source,csharp]
96+ ----
97+ var topLevelAggregation = Aggregation.Terms(new TermsAggregation
98+ {
99+ Field = Infer.Field<Person>(x => x.FirstName)
100+ });
101+
102+ topLevelAggregation.Aggregations = new Dictionary<string, Aggregation>
103+ {
104+ { "avg_age", new MaxAggregation
105+ {
106+ Field = Infer.Field<Person>(x => x.Age)
107+ }}
108+ };
109+
110+ var response = await client.SearchAsync<Person>(new SearchRequest("persons")
111+ {
112+ Query = Query.MatchAll(new MatchAllQuery()),
113+ Aggregations = new Dictionary<string, Aggregation>
114+ {
115+ { "firstnames", topLevelAggregation}
116+ },
117+ Size = 10
118+ });
119+ ----
120+
121+ [discrete]
122+ ==== Consuming the Response
73123==== Consume the response
74124
75125[source,csharp]
0 commit comments