Exemple #1
0
        public override IQueryResults Get([ModelBinder(typeof(ApiSearchRequestModelBinder))] ApiSearchRequest request)
        {
            //If an improper request is passed in return nothing
            if (string.IsNullOrEmpty(request?.PageId))
            {
                return(null);
            }

            var q = new SearchQuery <InformaSearchResultItem>(request, _parser);

            q.FilterPredicateBuilder = new InformaPredicateBuilder <InformaSearchResultItem>(_parser, request);
            q.QueryPredicateBuilder  = new InformaQueryPredicateBuilder <InformaSearchResultItem>(_queryFormatter, request);

            var results = _searchManager.GetItems(q);

            var multiSelectFacetResults = GetMultiSelectFacetResults(request);

            return(new QueryResults
            {
                Request = request,
                Results = results.Results,
                TotalResults = results.TotalResults,
                Facets = MergeFacets(results.Facets, multiSelectFacetResults)
            });
        }
        public IEnumerable <CompanyTypeAheadResponseItem> GetCompanies([ModelBinder(typeof(ApiSearchRequestModelBinder))] ApiSearchRequest request)
        {
            var q = new SearchQuery <InformaSearchResultItem>(request, _parser)
            {
                Take = 1,
                Skip = 0,
                FilterPredicateBuilder = new InformaPredicateBuilder <InformaSearchResultItem>(_parser, request),
                QueryPredicateBuilder  = new InformaQueryPredicateBuilder <InformaSearchResultItem>(_queryFormatter, request),
                FacetBuilder           = new CompaniesFacetBuilder(),
                SortBuilder            = null
            };
            var results = _searchManager.GetItems(q);

            return(results.Facets.FirstOrDefault()?.Values.Select(f => new CompanyTypeAheadResponseItem(f.Name)) ?? Enumerable.Empty <CompanyTypeAheadResponseItem>());
        }