diff --git a/docs/usage/aggregations.asciidoc b/docs/usage/aggregations.asciidoc index c52c950048..44f2f6d342 100644 --- a/docs/usage/aggregations.asciidoc +++ b/docs/usage/aggregations.asciidoc @@ -29,6 +29,26 @@ var response = await client ---- [discrete] +==== Object initializer API + +[source,csharp] +---- +var response = await client.SearchAsync(new SearchRequest("persons") +{ + Query = Query.MatchAll(new MatchAllQuery()), + Aggregations = new Dictionary + { + { "agg_name", Aggregation.Max(new MaxAggregation + { + Field = Infer.Field(x => x.Age) + })} + }, + Size = 10 +}); +---- + +[discrete] +==== Consuming the Response ==== Consume the response [source,csharp] @@ -70,6 +90,36 @@ var response = await client ---- [discrete] +==== Object initializer API + +[source,csharp] +---- +var topLevelAggregation = Aggregation.Terms(new TermsAggregation +{ + Field = Infer.Field(x => x.FirstName) +}); + +topLevelAggregation.Aggregations = new Dictionary +{ + { "avg_age", new MaxAggregation + { + Field = Infer.Field(x => x.Age) + }} +}; + +var response = await client.SearchAsync(new SearchRequest("persons") +{ + Query = Query.MatchAll(new MatchAllQuery()), + Aggregations = new Dictionary + { + { "firstnames", topLevelAggregation} + }, + Size = 10 +}); +---- + +[discrete] +==== Consuming the Response ==== Consume the response [source,csharp] diff --git a/docs/usage/query.asciidoc b/docs/usage/query.asciidoc index e4c6b5118e..b365825cdb 100644 --- a/docs/usage/query.asciidoc +++ b/docs/usage/query.asciidoc @@ -29,7 +29,7 @@ var response = await client var response = await client .SearchAsync(new SearchRequest("persons") { - Query = Query.Term(new TermQuery("firstName"!) + Query = Query.Term(new TermQuery(Infer.Field(x => x.FirstName)) { Value = "Florian" }),