public ApprenticeshipSearchResults SearchApprenticeships(string keywords, int pageNumber, int pageSize = 20, int sortOrder = 0, IEnumerable <int> selectedLevels = null)
        {
            var formattedKeywords = _queryHelper.FormatKeywords(keywords);

            var searchDescriptor = GetSearchDescriptor(pageNumber, pageSize, formattedKeywords, sortOrder, selectedLevels ?? Enumerable.Empty <int>());

            var results = _elasticsearchCustomClient.Search <ApprenticeshipSearchResultsDocument>(s => searchDescriptor);

            var levelAggregation = BuildLevelAggregationResult(results);

            return(MapToApprenticeshipSearchResults(pageNumber, pageSize, results, levelAggregation));
        }
Пример #2
0
        public List <ApprenticeshipSearchResultsItem> SearchApprenticeships(string keywords, int page)
        {
            var takeElements = 20;

            var formattedKeywords = _queryHelper.FormatKeywords(keywords);

            var searchDescriptor = GetSearchDescriptor(page, takeElements, formattedKeywords);

            var results = _elasticsearchCustomClient.Search <ApprenticeshipSearchResultsDocument>(s => searchDescriptor);

            return(results.Documents.Select(_resultDocumentMapping.MapToApprenticeshipSearchResultsItem).ToList());
        }
Пример #3
0
        public List <ProviderSearchResultsItem> SearchProviders(string keywords, int page)
        {
            if (keywords.Length < 3)
            {
                return(new List <ProviderSearchResultsItem>());
            }

            const int takeElements = 20;

            var formattedKeywords = _queryHelper.FormatKeywords(keywords);

            var searchDescriptor = GetSearchDescriptor(page, takeElements, formattedKeywords);

            var results = _elasticsearchCustomClient.Search <ProviderSearchResultsItem>(s => searchDescriptor);

            return(results.Documents.ToList());
        }