public static async Task <ContentSearchResult <T> > GetContentResultsAsync <T>( this IElasticSearchService <T> service, CancellationToken cancellationToken, bool requirePageTemplate, bool ignoreFilters, string[] providerNames, bool enableHighlighting, bool enableDidYouMean) where T : IContentData { SearchResult results = await service.GetResultsAsync(cancellationToken, enableHighlighting, enableDidYouMean, !ignoreFilters, DefaultFields.Id).ConfigureAwait(false); IEnumerable <Task <ContentSearchHit <T> > > tasks = results.Hits.Select(h => FilterAsync <T>(h, requirePageTemplate, providerNames, ignoreFilters)); ContentSearchHit <T>[] hits = await Task.WhenAll(tasks).ConfigureAwait(false); hits = hits.Where(h => h != null).ToArray(); results.TotalHits -= hits.Count(h => h == null); if (service.TrackSearch) { TrackingRepository.AddSearch( Language.GetLanguageCode(service.SearchLanguage), service.SearchText, results.TotalHits == 0, GetIndexName(service)); } return(new ContentSearchResult <T>(results, hits)); }
public static async Task <CatalogSearchResult <T> > GetCatalogResultsAsync <T>(this IElasticSearchService <T> service) where T : EntryContentBase { service.UseIndex(GetIndexName(service.SearchLanguage)); SearchResult results = await service.GetResultsAsync(); return(GetCatalogSearchResult(service, results)); }