public override async Task <SearchResult> SearchAsync(SearchQuery searchQuery, IDictionary <string, ISet <string> > tags = null, bool addPriceFilterTags = false, bool addNewsFilterTags = false, bool addCategoryFilterTags = false)
        {
            if (!_searchClientService.IsConfigured)
            {
                return(await _parent.SearchAsync(
                           searchQuery,
                           tags : tags,
                           addPriceFilterTags : addPriceFilterTags,
                           addNewsFilterTags : addNewsFilterTags,
                           addCategoryFilterTags : addCategoryFilterTags));
            }

            if (string.IsNullOrEmpty(searchQuery.Text) && searchQuery.CategorySystemId == Guid.Empty && searchQuery.ProductListSystemId == null)
            {
                return(null);
            }

            var response = await _searchClientService
                           .SearchAsync <ProductDocument>(CultureInfo.CurrentCulture, selector => selector
                                                          .Skip((searchQuery.PageNumber - 1) * searchQuery.PageSize)
                                                          .Size(searchQuery.PageSize)
                                                          .QueryWithPermission(queryContainerDescriptor => _searchQueryBuilder.BuildQuery(
                                                                                   queryContainerDescriptor,
                                                                                   searchQuery,
                                                                                   tags,
                                                                                   addPriceFilterTags,
                                                                                   addNewsFilterTags,
                                                                                   addCategoryFilterTags,
                                                                                   true))
                                                          .Source(s => s
                                                                  .Includes(i => i
                                                                            .Fields(
                                                                                f => f.IsBaseProduct,
                                                                                f => f.BaseProductSystemId,
                                                                                f => f.VariantSystemIds
                                                                                )
                                                                            )
                                                                  )
                                                          .Sort(sortDescriptor => _searchQueryBuilder.BuildSorting(
                                                                    sortDescriptor,
                                                                    searchQuery))
                                                          );

            return(Transform(searchQuery, unchecked ((int)response.Total), () =>
            {
                return _searchResultTransformationService.BuildSearchResultItems(
                    searchQuery,
                    response,
                    _requestModelAccessor.RequestModel.ChannelModel.SystemId);
            }));
        }
        public override SearchResponse Search(SearchQuery searchQuery, IDictionary <string, ISet <string> > tags = null, bool addPriceFilterTags = false, bool addNewsFilterTags = false, bool addCategoryFilterTags = false)
        {
            if (!_searchClientService.IsConfigured)
            {
                return(_parent.Search(
                           searchQuery,
                           tags: tags,
                           addPriceFilterTags: addPriceFilterTags,
                           addNewsFilterTags: addNewsFilterTags,
                           addCategoryFilterTags: addCategoryFilterTags));
            }

            if (string.IsNullOrEmpty(searchQuery.Text) && searchQuery.CategorySystemId == Guid.Empty && searchQuery.ProductListSystemId == null)
            {
                return(null);
            }

            return(new ElasticSearchResponse <ProductDocument>(_searchClientService
                                                               .Search <ProductDocument>(CultureInfo.CurrentUICulture, selector => selector
                                                                                         .Skip((searchQuery.PageNumber - 1) * searchQuery.PageSize)
                                                                                         .Size(searchQuery.PageSize)
                                                                                         .QueryWithPermission(queryContainerDescriptor => _searchQueryBuilder.BuildQuery(
                                                                                                                  queryContainerDescriptor,
                                                                                                                  searchQuery,
                                                                                                                  tags,
                                                                                                                  addPriceFilterTags,
                                                                                                                  addNewsFilterTags,
                                                                                                                  addCategoryFilterTags,
                                                                                                                  true))
                                                                                         .Sort(sortDescriptor => _searchQueryBuilder.BuildSorting(
                                                                                                   sortDescriptor,
                                                                                                   searchQuery))
                                                                                         )
                                                               ));
        }