public override List <SkinnyItem> GetItems(string databaseName,
                                                   string indexName,
                                                   string language,
                                                   string templateFilter,
                                                   bool searchBaseTemplates,
                                                   string locationFilter,
                                                   string fullTextQuery)
        {
            var searchParam = new NumericRangeSearchParam
            {
                Database            = databaseName,
                Ranges              = NumericRanges,
                LocationIds         = locationFilter,
                TemplateIds         = templateFilter,
                SearchBaseTemplates = searchBaseTemplates,
                FullTextQuery       = fullTextQuery,
                InnerCondition      = GetCondition(InnerNumericRangeConditionList),
                Language            = language
            };

            using (var runner = new QueryRunner(indexName))
            {
                return(runner.GetItems(searchParam));
            }
        }
        public static List <SkinnyItem> GetItems(string indexName,
                                                 string language,
                                                 string templateFilter,
                                                 string locationFilter,
                                                 string fullTextQuery,
                                                 List <NumericRangeSearchParam.NumericRangeField> ranges,
                                                 QueryOccurance occuranceTypeNumRanges = QueryOccurance.Must,
                                                 bool performSort     = false,
                                                 string sortFieldName = "",
                                                 bool reverse         = false)
        {
            var searchParam = new NumericRangeSearchParam
            {
                Database       = "web",
                Ranges         = ranges,
                LocationIds    = locationFilter,
                TemplateIds    = templateFilter,
                FullTextQuery  = fullTextQuery,
                InnerCondition = occuranceTypeNumRanges,
                Language       = language
            };

            using (var runner = new QueryRunner(indexName))
            {
                if (performSort)
                {
                    return(runner.GetItems(searchParam, sortField: sortFieldName, reverse: reverse));
                }
                else
                {
                    return(runner.GetItems(searchParam));
                }
            }
        }
예제 #3
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);
            }
        }
예제 #4
0
        public virtual List <SkinnyItem> 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));
        }
예제 #5
0
        public override List <SkinnyItem> GetItems(string databaseName,
                                                   string indexName,
                                                   string language,
                                                   string templateFilter,
                                                   string locationFilter,
                                                   string fullTextQuery)
        {
            var baseCondition = GetCondition(BaseOccuranceList);
            var outerNumParamParamCondition = GetCondition(NumericRangeOccuranceList);
            var outerDateParamCondition     = GetCondition(DateRangeOccuranceList);
            var innerNumParamParamCondition = GetCondition(InnerNumericRangeOccuranceList);
            var innerDateParamCondition     = GetCondition(InnerDateRangeOccuranceList);

            var baseSearchParam = new SearchParam
            {
                Database      = databaseName,
                LocationIds   = locationFilter,
                TemplateIds   = templateFilter,
                FullTextQuery = fullTextQuery,
                Language      = language,
                Condition     = baseCondition
            };

            var numSearchParam = new NumericRangeSearchParam
            {
                Ranges         = NumericRanges,
                InnerCondition = innerNumParamParamCondition,
                Condition      = outerNumParamParamCondition
            };

            var dateSearchParam = new DateRangeSearchParam
            {
                Ranges         = DateRanges,
                InnerCondition = innerDateParamCondition,
                Condition      = outerDateParamCondition
            };

            using (var runner = new QueryRunner(indexName))
            {
                return(runner.GetItems(new[] { baseSearchParam, numSearchParam, dateSearchParam }));
            }
        }
예제 #6
0
        public override List <SkinnyItem> GetItems(string indexName,
                                                   string language,
                                                   string templateFilter,
                                                   string locationFilter,
                                                   string fullTextQuery)
        {
            var searchParam = new NumericRangeSearchParam
            {
                Ranges          = Ranges,
                LocationIds     = locationFilter,
                TemplateIds     = templateFilter,
                FullTextQuery   = fullTextQuery,
                Occurance       = QueryOccurance.Must,
                Language        = language,
                ShowAllVersions = false
            };

            using (var searcher = new Searcher(indexName))
            {
                return(searcher.GetItemsInRange(searchParam));
            }
        }
        public static List <SkinnyItem> GetItems(string indexName,
                                                 string language,
                                                 string templateFilter,
                                                 string locationFilter,
                                                 string fullTextQuery,
                                                 string relationFilter,
                                                 List <MultiFieldSearchParam.Refinement> refinements,
                                                 QueryOccurance occuranceTypeRefinements,
                                                 List <DateRangeSearchParam.DateRange> dateRanges,
                                                 QueryOccurance occuranceTypeDateRanges,
                                                 List <NumericRangeSearchParam.NumericRangeField> numRanges,
                                                 QueryOccurance occuranceTypeNumRanges,
                                                 string fieldName,
                                                 string fieldValue,
                                                 bool canBePartial,
                                                 bool performSort     = false,
                                                 string sortFieldName = "",
                                                 bool reverse         = false)
        {
            var searchParam = new SearchParam
            {
                Database      = "web",
                RelatedIds    = relationFilter,
                Language      = language,
                TemplateIds   = templateFilter,
                LocationIds   = locationFilter,
                FullTextQuery = fullTextQuery
            };

            var searchParamMultiField = new MultiFieldSearchParam
            {
                Refinements    = refinements,
                InnerCondition = occuranceTypeRefinements
            };

            var searchParamDate = new DateRangeSearchParam
            {
                Ranges         = dateRanges,
                InnerCondition = occuranceTypeDateRanges
            };

            var searchParamNum = new NumericRangeSearchParam
            {
                Ranges         = numRanges,
                InnerCondition = occuranceTypeNumRanges
            };

            var searchParamField = new FieldSearchParam
            {
                FieldName  = fieldName,
                FieldValue = fieldValue,
                Partial    = canBePartial
            };

            using (var runner = new QueryRunner(indexName))
            {
                if (performSort)
                {
                    return(runner.GetItems(new[] { searchParam, searchParamMultiField, searchParamDate, searchParamField, searchParamNum }, sortField: sortFieldName, reverse: reverse));
                }
                else
                {
                    return(runner.GetItems(new[] { searchParam, searchParamMultiField, searchParamDate, searchParamField, searchParamNum }));
                }
            }
        }