Reputation: 226
How do you return group with counts using NEST client that returns only a paged result:
ElasticClient client = GetEsConnection(); //ignore the details
var searchResult = client.Search<Activity>(s=>s
.Index(ElasticSearchConstants.EntityActivitiesIndex)
.Type(ElasticSearchConstants.EntityActivitiesType)
.Query(q=>q.ConstantScore(cs=>cs.Filter(f=>f
.Bool(b=>b
.Must(GetActivitiesQuery(request))))))
.Fields(fields)
.Sort(ss=>ss.Descending(sortBy))
.Skip(0)
.Take(10));
On the above example Activity has a property called ActivityType and I want to return a summary count for each activity type. How can I do that?
Upvotes: 1
Views: 668
Reputation: 6357
It sounds like you want to use Terms aggregation
on the field ActivityType
. See the usage of terms aggregation using Nest here.
Upvotes: 2