-
-
Save RyanABailey/e9281a0dcb5160a51a1a to your computer and use it in GitHub Desktop.
Get Facets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var searchFacets = searchContext.GetQueryable<SearchModel>().Filter(searchPredicate).FacetOn(x => x.Category).GetFacets(); | |
| var categoryFacets = searchFacets.Categories.Where(x => x.Name == "categoryfacet").FirstOrDefault(); | |
| var facets = new List<SearchFacet>(); | |
| if(categoryFacets != null) | |
| { | |
| foreach (var facet in categoryFacets.Values) | |
| { | |
| facets.Add(new SearchFacet | |
| { | |
| Count = facet.AggregateCount, | |
| Value = facet.Name | |
| }); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class SearchFacet | |
| { | |
| public string Value { get; set; } | |
| public int Count { get; set; } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment