Пример #1
0
        public virtual List <SkinnyItem> GetItems(IEnumerable <SearchParam> parameters, QueryOccurance innerCondition, bool showAllVersions, Sort sorter, int start, int end, out int totalResults)
        {
            Assert.IsNotNull(Index, "Index");

            var translator = new QueryTranslator(Index);
            var query      = new BooleanQuery();

            foreach (var parameter in parameters.Where(p => p != null))
            {
                var nestedQuery = parameter.ProcessQuery(parameter.Condition, Index);

                if (nestedQuery == null)
                {
                    continue;
                }

                if (nestedQuery is BooleanQuery)
                {
                    if ((nestedQuery as BooleanQuery).Clauses().Count == 0)
                    {
                        continue;
                    }
                }

                query.Add(nestedQuery, translator.GetOccur(parameter.Condition));
            }

            return(RunQuery(query, showAllVersions, sorter, start, end, out totalResults));
        }
Пример #2
0
        /// <summary>
        /// The process query.
        /// </summary>
        /// <param name="condition">
        /// The condition.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// The <see cref="BooleanQuery"/>.
        /// </returns>
        public override Query ProcessQuery(QueryOccurance condition, Index index)
        {
            Assert.ArgumentNotNull(index, "Index");

            var baseQuery = base.ProcessQuery(condition, index);

            var translator = new QueryTranslator(index);

            Assert.IsNotNull(translator, "translator");

            var fieldQuery = this.Partial ? QueryBuilder.BuildPartialFieldValueClause(index, this.FieldName, this.FieldValue) :
                             QueryBuilder.BuildExactFieldValueClause(index, this.FieldName, this.FieldValue);

            if (baseQuery == null)
            {
                return(fieldQuery);
            }

            if (baseQuery is BooleanQuery)
            {
                var booleanQuery = baseQuery as BooleanQuery;
                booleanQuery.Add(fieldQuery, translator.GetOccur(condition));
            }

            return(baseQuery);
        }
        public override Query ProcessQuery(QueryOccurance condition, Index index)
        {
            Assert.ArgumentNotNull(index, "Index");

            var translator = new QueryTranslator(index);

            Assert.IsNotNull(translator, "Query Translator");

            var baseQuery = base.ProcessQuery(condition, index) as BooleanQuery ?? new BooleanQuery();

            var outerCondition = translator.GetOccur(condition);

            var query = this.BuildQuery(translator.GetOccur(InnerCondition));

            if (query != null)
            {
                baseQuery.Add(query, outerCondition);
            }

            return(baseQuery);
        }
Пример #4
0
        public override BooleanQuery ProcessQuery(QueryOccurance occurance, Index index)
        {
            var outerQuery = new BooleanQuery();

            var baseQuery      = base.ProcessQuery(occurance, index) ?? new BooleanQuery();
            var translator     = new QueryTranslator(index);
            var innerOccurance = translator.GetOccur(InnerCondition);
            var outerOccurance = translator.GetOccur(occurance);

            if (baseQuery.Clauses().Count > 0)
            {
                outerQuery.Add(baseQuery, outerOccurance);
            }

            var numericQuery = ApplyNumericRangeSearchParam(innerOccurance);

            if (numericQuery != null)
            {
                outerQuery.Add(numericQuery, outerOccurance);
            }

            return(outerQuery);
        }
Пример #5
0
        public virtual List <SkinnyItem> GetItemsInRange(DateRangeSearchParam 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);

            ApplyDateRangeSearchParam(booleanQuery, param, innerOccurance);

            return(RunQuery(booleanQuery, param.ShowAllVersions));
        }
Пример #6
0
        public virtual List <SkinnyItem> GetItems(IEnumerable <SearchParam> parameters, bool showAllVersions = false, string sortField = "", bool reverse = true, int start = 0, int end = 0)
        {
            Assert.IsNotNull(Index, "Index");

            var translator = new QueryTranslator(Index);
            var query      = new BooleanQuery();

            foreach (var parameter in parameters.Where(p => p != null))
            {
                var innerQueryResult = parameter.ProcessQuery(parameter.Condition, Index);
                if (innerQueryResult.GetClauses().Length > 0)
                {
                    var clause = new BooleanClause(innerQueryResult, translator.GetOccur(parameter.Condition));
                    query.Add(clause);
                }
            }

            return(RunQuery(query, showAllVersions, sortField, reverse, start, end));
        }
Пример #7
0
        public virtual BooleanQuery ProcessQuery(QueryOccurance occurance, Index index)
        {
            var innerQuery = new CombinedQuery();

            ApplyFullTextClause(innerQuery, FullTextQuery, occurance);
            ApplyRelationFilter(innerQuery, RelatedIds, occurance);
            ApplyTemplateFilter(innerQuery, TemplateIds, occurance);
            ApplyLocationFilter(innerQuery, LocationIds, occurance);
            AddFieldValueClause(innerQuery, BuiltinFields.Database, Database, occurance);

            if (innerQuery.Clauses.Count < 1)
            {
                return(null);
            }

            var translator   = new QueryTranslator(index);
            var booleanQuery = translator.ConvertCombinedQuery(innerQuery);

            ApplyLanguageClause(booleanQuery, Language, translator.GetOccur(occurance));

            return(booleanQuery);
        }
Пример #8
0
        /// <summary>
        /// The process query.
        /// </summary>
        /// <param name="condition">
        /// The condition.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// The <see cref="BooleanQuery"/>.
        /// </returns>
        public virtual Query ProcessQuery(QueryOccurance condition, Index index)
        {
            Assert.ArgumentNotNull(index, "Index");

            var translator = new QueryTranslator(index);

            Assert.IsNotNull(translator, "Query Translator");

            var templateFieldName = this.SearchBaseTemplates ? SearchFieldIDs.AllTemplates : BuiltinFields.Template;

            var queries = new List <Query>
            {
                QueryBuilder.BuildFullTextQuery(this.FullTextQuery, index),
                QueryBuilder.BuildRelationFilter(this.RelatedIds),
                QueryBuilder.BuildIdFilter(templateFieldName, this.TemplateIds),
                QueryBuilder.BuildLocationFilter(this.LocationIds),
                QueryBuilder.BuildFieldQuery(BuiltinFields.Database, this.Database),
                QueryBuilder.BuildLanguageQuery(this.Language)
            }
            .Where(q => q != null)
            .ToList();

            if (!queries.Any())
            {
                return(null);
            }

            var occur        = translator.GetOccur(condition);
            var booleanQuery = new BooleanQuery();

            foreach (var query in queries)
            {
                booleanQuery.Add(query, occur);
            }

            return(booleanQuery);
        }
Пример #9
0
        public override BooleanQuery ProcessQuery(QueryOccurance occurance, Index index)
        {
            var outerQuery = new BooleanQuery();

            var refinementQuery = ApplyRefinements(Refinements, InnerCondition);

            var translator      = new QueryTranslator(index);
            var refBooleanQuery = translator.ConvertCombinedQuery(refinementQuery);
            var outerOccurance  = translator.GetOccur(occurance);

            if (refBooleanQuery != null && refBooleanQuery.Clauses().Count > 0)
            {
                outerQuery.Add(refBooleanQuery, outerOccurance);
            }

            var baseQuery = base.ProcessQuery(occurance, index);

            if (baseQuery != null)
            {
                outerQuery.Add(baseQuery, outerOccurance);
            }

            return(outerQuery);
        }