Пример #1
0
        private void BindRelatedItemRepeater()
        {
            IEnumerable<Guid> categories =
                Sitecore.Context.Item.Fields["Categories"].Value.Split("|".ToCharArray(),
                    StringSplitOptions.RemoveEmptyEntries).Select(Parse).Where(a=>a!=Guid.Empty);

            IIndexSearchService searchService = new IndexSearchService(new QueryBuilder(true));

            SearchParameters parameters = SearchResultsManager.BuildSearchParameters();

            parameters.Facets.Clear();

            parameters.Facets.Add(new SearchParametersFacet
            {
                Name = "Categories",
                SelectedValues = categories.Select(SearchResultsManager.Clean)
            });

            var results = searchService.Search(parameters);

            RelatedItemRepeater.DataSource = results.SearchResults
                .Where(a => a.Guid != Sitecore.Context.Item.ID.Guid)
                .Take(5)
                .Select(b => Sitecore.Context.Database.GetItem(b));

            RelatedItemRepeater.DataBind();
        }
Пример #2
0
        private void RunSearch()
        {
            IIndexSearchService searchService = new IndexSearchService(new QueryBuilder());

            var results = searchService.Search(BuildSearchParameters());

            ResultsPlaceHolder.Visible = results.TotalHits > 0;

            NoResultsPlaceHolder.Visible = results.TotalHits == 0;

            if (results.TotalHits > 0)
            {
                BindFacetNavigation(results.FacetCategories);

                DumpSearchResults(results.SearchResults);

                SearchResultsPagination.TotalPages = results.TotalHits / SearchResultsManager.ResultsPerPage;
            }
        }