November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Why don't you make the CreatorUserId a facet? Then you'll get the results back faceted on that, with the counts. You can still combine with a pre and/or post filter.
Dan's suggestion works a treat. I had to make my property a string but that wasn't an issue. Here's the solution:
public class TopicIndex { public string CreatorUserId { get; set; } public int ItemCategory { get; set; } } var docs = _searchClient.Search<TopicIndex>() .Filter(x => x.ItemCategory.Match(1)) .TermsFacetFor(x => x.CreatorUserId) .Take(0) .GetResult(); var topAuthors = docs.TermsFacetFor(x => x.CreatorUserId) .Terms .OrderByDescending(t => t.Count) .Select(t => new { UserId = t.Term, Count = t.Count });
I'm trying to sort some results from EPiServer Find using the count of a grouping like function. However, I can't see how I would achieve this with the Find API's. At the moment I'm having to get documents back from Find (filtered by a certain value) and then do the grouping and sorting in memory with Linq to objects. Below is a summary of my indexed type and code:
Any ideas how I could achieve this just using Find?
Thanks.