@@ -29,6 +29,26 @@ var response = await client
29
29
----
30
30
31
31
[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
32
52
==== Consume the response
33
53
34
54
[source,csharp]
@@ -70,6 +90,36 @@ var response = await client
70
90
----
71
91
72
92
[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
73
123
==== Consume the response
74
124
75
125
[source,csharp]
0 commit comments