Would like to use groupby clause in Sitecore 9.1.1 for both search provide (Azure, Solr) in content search API. However, Sitecore does not support this clause. Kindly let us know how we can group result based on common categories so it would work on both (Solr and Azure) search provider.

1 Answer 1


Categorizing can be achieved with faceting, using the FacetOn method. Official documentation can be found here.

Simple faceting

var results = queryable.FacetOn(d => d.Name); 
var facets = results.GetFacets(); 
foreach (var category in facets.Categories) { 
    foreach (var facetValue in category.Values) { 
        Console.WriteLine("{0}: {1}", facetValue.Name, facetValue.Aggregate); 

With the code above, you can get the facets which are used by your items. facetValue.Name is the Guid of the items, so based on this you can get the items from Sitecore to show additional data from the item.

  • We would like to show results in group such as Computer category records would show in group (for example 10 records related to computer category show in group and after that other category result would show) . Is this possible through FacetOn?
    – Ashu
    Oct 27, 2020 at 10:05
  • @user3283738 that's not possible with FacetOn as far as I know. For that you would need to use the Azure Search SDK and SolrNet and not using the Sitecore Content Search API. Oct 27, 2020 at 11:09
  • @user3283738 I updated my answer. With the trick above should be possible to achieve what you want. Oct 27, 2020 at 11:21
  • I will try faceton approach and let you know. However, I am using content search API so SolrNet and Azure search SDK won't work in my scenario.
    – Ashu
    Oct 27, 2020 at 12:49
  • @user3283738 did this approach work for you? Oct 29, 2020 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.