Trouble in Composite aggregation in new ElasticSearchClient Library in dotnet

Hi,
I am trying some aggregation code in C# code in dotnet8.0
using Elastic.Clients.Elasticsearch library version 8.15.10

Previously, when using NEST this was used as Composite aggregation,

.Aggregations(
    a => a.Composite(c => c
        .Sources(cs => cs
            .DateHistogram("date", dh => dh
                .Field(f => f.EventDate)
                .CalendarInterval(CalendarInterval.Day)
                .Format("yyyy-MM-dd")
            )
            .Terms("tenant", t => t
                .Field(f => f.TenantId)
            )
        )
    )
)

But now, when I have tried a lot to reproduce in new Elastic.Clients.Elasticsearch library version 8.15.10, i am unable to succeed.

i was able to figure out like this for simple aggregation

  .Aggregations(a =>a.
            Add("hits_over_time", dh => dh.DateHistogram(a=>a
                .Field(p => p.EventDate)
                .CalendarInterval(CalendarInterval.Day)
                .Format("yyyy-MM-dd")
              )
            ))

But unable to get it for composite aggregation.

I feel availablity of new dotnet client document will greatly help
So, can someone guide me how to reproduce this scenario?

Hi @MARYALA_VINAY_KUMAR ,

this complex case scenario (nested aggregations) is documented here:

I think we have to improve usability of this. The composite aggregation is a little bit different and the code generation does not output the best possible API. Something like this should work:

var response = await client.SearchAsync<Person>(s => s
	.Aggregations(aggs => aggs
		.Add("composite", agg => agg
			.Composite(composite => composite
				.Sources([
					new Dictionary<string, CompositeAggregationSource>
					{
						{ "date", new CompositeAggregationSource
						{
							DateHistogram = new CompositeDateHistogramAggregation
							{
								//...
							}
						} },
						{ "terms", new CompositeAggregationSource
						{
							Terms = new CompositeTermsAggregation
							{
								//...
							}
						} }
					}
				])
			)
		)
	)
);

We already have an open issue for this: