Example #1
0
 protected void AddNumericRangeQuery(BooleanQuery query, NumericRangeSearchParam.NumericRangeField range, BooleanClause.Occur occurance)
 {
     var startTerm = new Term(range.FieldName, SearchHelper.FormatNumber(range.Start));
      var endTerm = new Term(range.FieldName, SearchHelper.FormatNumber(range.End));
      var rangeQuery = new RangeQuery(startTerm, endTerm, true);
      query.Add(rangeQuery, occurance);
 }
Example #2
0
        protected void ApplyNumericRangeSearchParam(BooleanQuery query, NumericRangeSearchParam param, BooleanClause.Occur innerOccurance)
        {
            if (param.Ranges.Count <= 0) return;

             foreach (var range in param.Ranges)
             {
            AddNumericRangeQuery(query, range, innerOccurance);
             }
        }
Example #3
0
        public virtual List<SitecoreItem> GetItemsInRange(NumericRangeSearchParam param)
        {
            var globalQuery = new CombinedQuery();

             ApplyLanguageClause(globalQuery, param.Language);
             ApplyTemplateFilter(globalQuery, param.TemplateIds);
             ApplyLocationFilter(globalQuery, param.LocationIds);
             ApplyFullTextClause(globalQuery, param.FullTextQuery);

             var translator = new QueryTranslator(Index);
             var booleanQuery = translator.ConvertCombinedQuery(globalQuery);
             var innerOccurance = translator.GetOccur(param.Occurance);

             ApplyNumericRangeSearchParam(booleanQuery, param, innerOccurance);

             return RunQuery(booleanQuery, param.ShowAllVersions);
        }