public virtual ISearchResults FindAll(int skip, int take) { using (var context = ContentSearchManager.GetIndex(this.ContextItem).CreateSearchContext()) { IQueryable <SearchResultItem> queryableTest = (IQueryable <SearchResultItem>)context.GetQueryable <SearchResultItem>(); var testResults = queryableTest.GetResults(); //ß Throw exception foreach (var result in testResults) { var resultName = result.Document.Name; } var testList = queryableTest.ToList(); //Return Empty List var queryable = this.CreateAndInitializeQuery(context); if (skip > 0) { queryable = queryable.Skip(skip); } if (take > 0) { queryable = queryable.Take(take); } var results = queryable.GetResults(); return(SearchResultsFactory.Create(results, null)); } }
public virtual ISearchResults Search(IQuery query, bool isAutoComplete = false) { using (var context = ContentSearchManager.GetIndex(this.ContextItem).CreateSearchContext()) { var queryable = this.CreateAndInitializeQuery(context); if (this.Settings.Templates == null || !this.Settings.Templates.Any()) { queryable = this.FilterOnItemsMarkedAsIndexable(queryable); } if (isAutoComplete) { queryable = this.AddContentTitlePredicates(queryable, query); } else { queryable = this.AddContentPredicates(queryable, query); } queryable = this.AddFacets(queryable); if (query.IndexOfFirstResult > 0) { queryable = queryable.Skip(query.IndexOfFirstResult); } if (query.NoOfResults > 0) { queryable = queryable.Take(query.NoOfResults); } var results = queryable.GetResults(); return(SearchResultsFactory.Create(results, query)); } }
public virtual ISearchResults Search(IQuery query) { using (var context = ContentSearchManager.GetIndex(this.ContextItem).CreateSearchContext()) { var root = this.Settings.Root; var queryable = context.GetQueryable <SearchResultItem>(); queryable = this.SetQueryRoot(queryable, root); queryable = this.FilterOnPresentationOnly(queryable); queryable = this.FilterOnLanguage(queryable); queryable = this.FilterOnVersion(queryable); if (this.Settings.Templates != null && this.Settings.Templates.Any()) { queryable = queryable.Cast <IndexedItem>().Where(this.GetTemplatePredicates(this.Settings.Templates)); } else { queryable = this.FilterOnTemplates(queryable); } queryable = this.AddContentPredicates(queryable, query); queryable = AddFacets(queryable); if (query.IndexOfFirstResult > 0) { queryable = queryable.Skip(query.IndexOfFirstResult); } if (query.NoOfResults > 0) { queryable = queryable.Take(query.NoOfResults); } var results = queryable.GetResults(); return(SearchResultsFactory.Create(results, query)); } }
public virtual ISearchResults FindAll(int skip, int take) { using (var context = ContentSearchManager.GetIndex(this.ContextItem).CreateSearchContext()) { var root = this.Settings.Root; var queryable = context.GetQueryable <SearchResultItem>(); queryable = this.SetQueryRoot(queryable, root); queryable = this.FilterOnLanguage(queryable); queryable = this.FilterOnVersion(queryable); queryable = this.FilterOnHasSearchResultFormatter(queryable); queryable = queryable.Where(PredicateBuilder.True <SearchResultItem>()); if (this.Settings.Templates != null && this.Settings.Templates.Any()) { queryable = queryable.Cast <IndexedItem>().Where(this.GetTemplatePredicates(this.Settings.Templates)); } if (skip > 0) { queryable = queryable.Skip(skip); } if (take > 0) { queryable = queryable.Take(take); } var results = queryable.GetResults(); return(SearchResultsFactory.Create(results, null)); } }
public virtual ISearchResults FindAll(int skip, int take) { using (var context = ContentSearchManager.GetIndex(this.ContextItem).CreateSearchContext()) { var queryable = this.CreateAndInitializeQuery(context); if (skip > 0) { queryable = queryable.Skip(skip); } if (take > 0) { queryable = queryable.Take(take); } var results = queryable.GetResults(); return(SearchResultsFactory.Create(results, null)); } }