private Sitecore.ContentSearch.Linq.FacetResults ExecuteGetFacets(AzureQuery query) { var query1 = query; var list = new List <FacetQuery>(query.FacetQueries); var facetQueries = GetFacetsPipeline.Run(pipeline, new GetFacetsArgs(null, query.FacetQueries, context.Index.Configuration.VirtualFields, context.Index.FieldNameTranslator)).FacetQueries; var facets = new Dictionary <string, ICollection <KeyValuePair <string, int> > >(); foreach (var facetQuery in facetQueries) { foreach (var keyValuePair in GetFacets(query1, facetQuery.FieldNames, new int?(1), Enumerable.Cast <string>(facetQuery.FilterValues), new bool?(), null, facetQuery.MinimumResultCount)) { facets[facetQuery.CategoryName] = keyValuePair.Value; } } var dictionary = ProcessFacetsPipeline.Run(pipeline, new ProcessFacetsArgs(facets, query.FacetQueries, list, context.Index.Configuration.VirtualFields, context.Index.FieldNameTranslator)); foreach (var facetQuery in list) { var originalQuery = facetQuery; if (originalQuery.FilterValues != null && Enumerable.Any(originalQuery.FilterValues) && dictionary.ContainsKey(originalQuery.CategoryName)) { var collection = dictionary[originalQuery.CategoryName]; dictionary[originalQuery.CategoryName] = Enumerable.ToList(Enumerable.Where(collection, (cv => Enumerable.Contains(originalQuery.FilterValues, cv.Key)))); } } var facetResults = new Sitecore.ContentSearch.Linq.FacetResults(); foreach (var keyValuePair in dictionary) { IEnumerable <FacetValue> values = Enumerable.Select(keyValuePair.Value, v => new FacetValue(v.Key, v.Value)); facetResults.Categories.Add(new FacetCategory(keyValuePair.Key, values)); } return(facetResults); }
private SearchResults <TDocument> ExecuteGetResults <TDocument>(AzureQuery query, AzureSearchResults <TDocument> processedResults, DocumentSearchResult results) { var searchHits = processedResults.GetSearchHits(); Sitecore.ContentSearch.Linq.FacetResults facets = null; if (query.FacetQueries != null && query.FacetQueries.Count > 0) { facets = ExecuteGetFacets(query); } return(new SearchResults <TDocument>(searchHits, (int)results.Count, facets)); }