public ActionResult ExperimentalSearch(SearchParameters parameters)
        {
            throw new HttpException(404, "Search disabled");

            try
            {
                ISolrReadOnlyOperations<Searchable> solr =
                    Startup.Container.GetInstance<ISolrReadOnlyOperations<Searchable>>();
                var queryOptions = parameters.ToQueryOptions();
                var matchingSearchables = solr.Query(parameters.BuildQuery(), queryOptions);
                var results = new SearchableView
                {
                    Searchables = matchingSearchables,
                    Search = parameters,
                    TotalCount = matchingSearchables.NumFound,
                    Highlights = matchingSearchables.Highlights,
                    CollapseResults = matchingSearchables.Collapsing,
                    SuperSearchables = SuperSearchable.Parse(matchingSearchables),
                    Facets = matchingSearchables.FacetFields,
                    DidYouMean = GetSpellCheckingResult(matchingSearchables),
                    QueryTime = matchingSearchables.Header.QTime,

                    PaginationInfo = new PaginationInfo
                    {
                        PageUrl = Url.SetParameter("page", "!0"),
                        CurrentPage = parameters.PageIndex,
                        PageSize = parameters.PageSize,
                        TotalItemCount = matchingSearchables.NumFound,
                    }
                };
                var view = new ExperimentalSearchViewModel()
                {
                    Results = results,
                };

                return View(view);
            }
            catch (InvalidFieldException)
            {
                return View(new SearchableView
                {
                    QueryError = true,
                });
            }
        }
Exemple #2
0
 public SearchableView()
 {
     Search = new SearchParameters();
     Facets = new Dictionary<string, ICollection<KeyValuePair<string, int>>>();
     Searchables = new List<Searchable>();
 }