/// <summary> /// Deferred Execution of the Search /// </summary> public static IEnumerable <SitecoreItem> Run(this BucketQuery query, Item startLocationItem, int numberOfHits) { var returnQuery = query.Select(subQuery => new SearchStringModel() { Type = subQuery.Split(':')[0], Value = subQuery.Split(':')[1] }).ToList(); int hitCount = 0; numberOfHits = hitCount; return(startLocationItem.Search(returnQuery, out hitCount)); }
/// <summary> /// Deferred Execution of the Search /// </summary> public static IEnumerable <SitecoreItem> First(this BucketQuery query) { var returnQuery = query.Select(subQuery => new SearchStringModel() { Type = subQuery.Split(':')[0], Value = subQuery.Split(':')[1] }).ToList(); int hitCount = 0; return(Sitecore.Context.Item.Search(returnQuery, out hitCount, numberOfItems: 1, pageNumber: 1)); }
/// <summary> /// Deferred Execution of the Search /// </summary> public static IEnumerable <SitecoreItem> Skip(this BucketQuery query, int count, out int numberOfHits, int skipToPage) { var returnQuery = query.Select(subQuery => new SearchStringModel() { Type = subQuery.Split(':')[0], Value = subQuery.Split(':')[1] }).ToList(); int hitCount = 0; numberOfHits = hitCount; return(Sitecore.Context.Item.Search(returnQuery, out hitCount, numberOfItems: count, pageNumber: skipToPage)); }
/// <summary> /// Deferred Execution of the Search /// </summary> public static IEnumerable <SitecoreItem> Run(this BucketQuery query, out int numberOfHits) { var returnQuery = query.Select(subQuery => new SearchStringModel() { Type = subQuery.Split(':')[0], Value = subQuery.Split(':')[1] }).ToList(); int hitCount = 0; numberOfHits = hitCount; return(BucketManager.Search(Sitecore.Context.Item, out hitCount, returnQuery)); }
/// <summary> /// Sort by a particular field name and Run the query /// </summary> public static IEnumerable <SitecoreItem> SortBy(this BucketQuery query, string fieldName, SortDirection sortDirection, out int numberOfHits, int page, int numberOfItemsPerPage) { query.Add("sort:" + fieldName); var returnQuery = query.Select(subQuery => new SearchStringModel() { Type = subQuery.Split(':')[0], Value = subQuery.Split(':')[1] }).ToList(); int hitCount = 0; numberOfHits = hitCount; return(Sitecore.Context.Item.Search(returnQuery, out hitCount, pageNumber: page, numberOfItems: numberOfItemsPerPage, sortDirection: sortDirection == SortDirection.Ascending ? "asc" : "desc")); }
/// <summary> /// Deferred Execution of the Search /// </summary> public static bool AnyResults(this BucketQuery query) { var returnQuery = query.Select(subQuery => new SearchStringModel() { Type = subQuery.Split(':')[0], Value = subQuery.Split(':')[1] }).ToList(); int hitCount = 0; var blah = new List <String>(); Sitecore.Context.Item.Search(returnQuery, out hitCount, numberOfItems: 1, pageNumber: 1); return(hitCount > 0); }