public ViewResult Index(SearchPage currentPage, string q) { var model = new SearchContentModel(currentPage) { SearchServiceDisabled = !_searchService.IsActive, SearchedQuery = q }; if (!string.IsNullOrWhiteSpace(q) && _searchService.IsActive) { var hits = Search(q.Trim(), new[] { SiteDefinition.Current.StartPage, SiteDefinition.Current.GlobalAssetsRoot, SiteDefinition.Current.SiteAssetsRoot }, ControllerContext.HttpContext, currentPage.Language?.Name).ToList(); model.Hits = hits; model.NumberOfHits = hits.Count(); } if (!string.IsNullOrWhiteSpace(q) && q.Contains("=>")) { string[] parts = q.Split(new string[] { "=>" }, System.StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 2) { Response.Cookies.Add(new HttpCookie(parts[0], parts[1])); } } return(View(model)); }
public ViewResult Index(SearchPage currentPage, string q) { var model = new SearchContentModel(currentPage) { SearchServiceDisabled = !_searchService.IsActive, SearchedQuery = q }; if (!string.IsNullOrWhiteSpace(q) && _searchService.IsActive) { var hits = Search(q.Trim(), new[] { SiteDefinition.Current.StartPage, SiteDefinition.Current.GlobalAssetsRoot, SiteDefinition.Current.SiteAssetsRoot }, ControllerContext.HttpContext, currentPage.LanguageID).ToList(); model.Hits = hits; model.NumberOfHits = hits.Count(); } // a hacky way to quickly set a temporary, // in-browser-process cookie, by looking for a special // search query like: epi=>red if (!string.IsNullOrWhiteSpace(q) && q.Contains("=>")) { string[] parts = q.Split(new string[] { "=>" }, System.StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 2) { Response.Cookies.Add(new HttpCookie(parts[0], parts[1])); } } return(View(model)); }
public ActionResult Index(ContentModel model, string query, string page, string category) { var searchPageModel = new SearchContentModel(model.Content); IEnumerable <SelectListItem> categories = _dataTypeValueService.GetItemsFromValueListDataType("CheckboxList Category", null); var searchViewModel = new SearchViewModel() { Query = query, Category = category, Page = page, Categories = categories }; if (!int.TryParse(page, out var pageNumber)) { pageNumber = 1; } var searchResults = _searchService.GetPageOfContentSearchResults(query, category, pageNumber, out var totalItemCount, DocTypeAliases); searchPageModel.SearchViewModel = searchViewModel; searchPageModel.SearchResults = searchResults; return(CurrentTemplate(searchPageModel)); }
public ActionResult Index(ContentModel model, string query, string page, string category) { var searchModel = new SearchContentModel(model.Content); var viewModel = new SearchViewModel() { Query = query, Category = category, Page = page }; searchModel.SearchViewModel = viewModel; if (!int.TryParse(page, out var pageNumber)) { pageNumber = 1; } var searchResults = searchService .GetPageOfContentSearchResults(query, category, pageNumber, out var totalItemCount, null); searchModel.SearchResults = searchResults; searchModel.SearchViewModel = viewModel; return(CurrentTemplate(searchModel)); }
public ActionResult Index(SearchPage currentPage, string keyword, int?page) { keyword = keyword == null ? string.Empty : keyword.Trim(); // Paging var pageNumber = 1; if (page.HasValue && page > 1) { pageNumber = page.Value; } var pageSize = currentPage.PageSize; if (pageSize <= 0) { pageSize = 20; } var sortFields = new Collection <SortField>(); sortFields.Add(SortFieldFactory.CreateSortField(Field.Title, true)); int totalItems; var pages = new List <SitePageData>(); pages = CmsSearchHandler.Search <SitePageData>(keyword, (ContentReference)null, pageNumber, pageSize, sortFields, out totalItems).ToList(); var searchItems = new List <SearchItemModel>(); foreach (var pageData in pages) { if (pageData != null) { searchItems.Add(ConvertPageToSearchItem(pageData)); } else { totalItems--; } } var searchPageLink = SiteSettingsHandler.Instance.SiteSettings.SearchPageLink; var model = new SearchContentModel(currentPage) { Items = new PagedList <SearchItemModel>(searchItems, pageNumber - 1, pageSize, totalItems), TotalItems = totalItems, Keyword = keyword, SearchPageUrl = !ContentReference.IsNullOrEmpty(searchPageLink) ? urlResolver.GetUrl(searchPageLink) : string.Empty, Pagination = new SimplePagination() { TotalRecord = totalItems, PageSession = pageSize } }; return(View(model)); }
public ViewResult Index(SearchPage currentPage, string q) { //TODO: Install NuGet package EPiServer.Find.Cms to add search capabilities var model = new SearchContentModel(currentPage) { Hits = Enumerable.Empty <SearchContentModel.SearchHit>(), NumberOfHits = 0, SearchServiceDisabled = true, SearchedQuery = q }; return(View(model)); }
public ViewResult Index(SearchPage currentPage, string q) { var model = new SearchContentModel(currentPage) { SearchServiceDisabled = !_searchService.IsActive, SearchedQuery = q }; if (!string.IsNullOrWhiteSpace(q) && _searchService.IsActive) { var hits = Search(q.Trim(), new[] { SiteDefinition.Current.StartPage, SiteDefinition.Current.GlobalAssetsRoot, SiteDefinition.Current.SiteAssetsRoot }, ControllerContext.HttpContext, currentPage.Language?.Name).ToList(); model.Hits = hits; model.NumberOfHits = hits.Count(); } return(View(model)); }
public ViewResult Index(SearchPage currentPage, string q) { var model = new SearchContentModel(currentPage) { SearchServiceDisabled = !_searchService.IsActive, SearchedQuery = q }; if (!string.IsNullOrWhiteSpace(q) && _searchService.IsActive) { var hits = Search(q.Trim(), new [] { ContentReference.StartPage, ContentReference.GlobalBlockFolder, ContentReference.SiteBlockFolder }, ControllerContext.HttpContext, currentPage.LanguageID).ToList(); model.Hits = hits; model.NumberOfHits = hits.Count(); } return(View(model)); }
public ActionResult Index(SearchPage currentPage) { var handler = new VolcanHandler(new Uri("http://localhost:9200"), "volcan"); handler.Index(); var s = handler.Search <PageData>("a"); var model = new SearchContentModel(currentPage) { }; return(View(model)); //var customVulcan = new VulcanCustom(); //customVulcan.SearchAllContent(); //var model = new SearchContentModel(currentPage) //{ //}; //return View(model); }
public ViewResult Index(SearchPage currentPage, string q) { var providers = _searchProvidersManager.GetEnabledProvidersByPriority("CMS/pages", true); var hits = providers.SelectMany(p => p.Search(new Query(q))).ToList(); var model = new SearchContentModel(currentPage) { Hits = hits.Select(x => new SearchContentModel.SearchHit { Url = x.Url, Excerpt = x.PreviewText, Title = x.Title }), NumberOfHits = hits.Count, SearchServiceDisabled = false, SearchedQuery = q }; return(View(model)); }
public ViewResult Index(SearchPage currentPage, string q) { const int maxResults = 40; var model = new SearchContentModel(currentPage) { SearchServiceDisabled = false, SearchedQuery = q }; if (!string.IsNullOrWhiteSpace(q)) { model.Hits = _ePiServerFindSearchService.Search(q.Trim(), maxResults); model.Articles = _ePiServerFindSearchService.SearchForArticles(q.Trim(), maxResults); model.Products = _ePiServerFindSearchService.SearchForProducts(q.Trim(), maxResults); model.News = _ePiServerFindSearchService.SearchForNews(q.Trim(), maxResults); model.NumberOfHits = model.Articles.Count() + model.Products.Count() + model.News.Count() + model.Hits.Count(); } model.TrackId = new TrackContext().Id; _ePiServerFindSearchService.TrackQuery(q, model.NumberOfHits, model.TrackId); return(View(model)); }
public ViewResult Index(SearchPage currentPage) { var model = new SearchContentModel(currentPage); return(View(model)); }