示例#1
0
        //public virtual List<SitecoreItem> GetItemsViaTermQuery(string fieldName, string fieldValue)
        //{
        //   var query = new TermQuery(new Term(fieldName, fieldValue));
        //   return RunQuery(query, false);
        //}
        //public virtual List<SitecoreItem> GetItemsViaFieldQuery(string fieldName, string fieldValue)
        //{
        //   var query = new FieldQuery(fieldName, fieldValue);
        //   return RunQuery(query, false);
        //}
        public virtual List<SitecoreItem> GetItems(SearchParam param)
        {
            var globalQuery = new CombinedQuery();

             ApplyLanguageClause(globalQuery, param.Language);
             if (!String.IsNullOrWhiteSpace(param.FullTextQuery))
             {
             ApplyFullTextClause(globalQuery, param.FullTextQuery);
             }
             ApplyRelationFilter(globalQuery, param.RelatedIds);
             ApplyTemplateFilter(globalQuery, param.TemplateIds);
             ApplyLocationFilter(globalQuery, param.LocationIds);

             return RunQuery(globalQuery, param.ShowAllVersions);
        }
        protected virtual List<SitecoreItem> GetItems()
        {
            var searchParam = new SearchParam
            {
                Language = Lang,
                TemplateIds = GetTemplates(FullTextQuery),
                LocationIds = LocationFilter,
                FullTextQuery = GetText(FullTextQuery),
                ShowAllVersions = false
            };

            //var dateRange = new DateRangeSearchParam
            //{
            //    Language = Lang,
            //    TemplateIds = GetTemplates(FullTextQuery),
            //    LocationIds = LocationFilter,
            //    FullTextQuery = GetText(FullTextQuery),
            //    ShowAllVersions = false,
            //    Ranges = new List<DateRangeSearchParam.DateRangeField>()
            //                                     {
            //                                         new DateRangeSearchParam.DateRangeField("__Created",
            //                                                                                 Convert.ToDateTime(GetStartDate(FullTextQuery)),
            //                                                                                 Convert.ToDateTime(GetEndDate(FullTextQuery)))
            //                                     }

            //};

            using (var searcher = new ItemBucket.Kernel.Kernel.Util.IndexSearcher(IndexName))
            {
                return searcher.GetItems(searchParam);
            }
        }
示例#3
0
        protected virtual List<SitecoreItem> GetItems(string term)
        {
            var searchParam = new SearchParam
            {
                Language = Lang,
                TemplateIds = "",
                LocationIds = LocationFilter,
                FullTextQuery = term,
                ShowAllVersions = false
            };

            using (var searcher = new IndexSearcher(IndexName))
            {
                return searcher.GetItems(searchParam);
            }
            //using (var searcher = new Searcher.Searcher(IndexName))
            //{
            //    return searcher.GetItemsInRange(dateRange);
            //}
        }