/// <summary>
 /// An extension of Item that allows you to launch a Search from an item
 /// </summary>
 /// <returns>List of Results of Type IEnumerable List of SitecoreItem (which implements IItem)</returns>
 /// <param name="startLocationItem">The start location of the search</param>
 /// <param name="queryParser">The raw JSON Parse query</param>
 /// <param name="hitCount">This will output the hitCount of the search</param>
 /// <param name="indexName">Force query to run on a particular index</param>
 public static IEnumerable<SitecoreItem> Search(Item startLocationItem, SearchParam queryParser, out int hitCount, string indexName = "itembuckets_buckets")
 {
     using (var searcher = new IndexSearcher(indexName))
     {
         var keyValuePair = searcher.GetItems(queryParser);
         hitCount = keyValuePair.Key;
         return keyValuePair.Value;
     }
 }
Esempio n. 2
0
        internal virtual KeyValuePair<int, List<SitecoreItem>> GetItems(SearchParam param)
        {
            var globalQuery = new CombinedQuery();
            SearcherMethods.ApplyLanguageClause(globalQuery, param.Language);
            if (!string.IsNullOrWhiteSpace(param.FullTextQuery))
            {
                SearcherMethods.ApplyFullTextClause(globalQuery, param.FullTextQuery);
            }

            SearcherMethods.ApplyRelationFilter(globalQuery, param.RelatedIds);
            SearcherMethods.ApplyTemplateFilter(globalQuery, param.TemplateIds);
            SearcherMethods.ApplyLocationFilter(globalQuery, param.LocationIds);
            SearcherMethods.ApplyRefinements(globalQuery, param.Refinements, QueryOccurance.Must);

            return this.RunQuery(globalQuery);
        }