Ejemplo n.º 1
0
        public IEnumerable <int> Execute(string lucQuery)
        {
            var query      = LucQuery.Parse(lucQuery);
            var lucObjects = query.Execute();

            return(from lucObject in lucObjects select lucObject.NodeId);
        }
Ejemplo n.º 2
0
        public static IEnumerable <LucObject> GetAllDocumentVersionsByNodeId(int nodeId)
        {
            var queryText = String.Concat(LucObject.FieldName.NodeId, ":", nodeId, " .AUTOFILTERS:OFF");
            var query     = LucQuery.Parse(queryText);
            var result    = query.Execute(true);

            return(result);
        }
Ejemplo n.º 3
0
            private static InnerQueryResult ExecuteInnerScript(string src, int top, int skip,
                                                               IEnumerable <SortInfo> sort, FilterStatus enableAutofilters, FilterStatus enableLifespanFilter,
                                                               QuerySettings settings, bool enableProjection, out int count, out QueryTraceInfo traceInfo)
            {
                LucQuery query;

                try
                {
                    query = LucQuery.Parse(src);
                }
                catch (ParserException ex)
                {
                    throw new InvalidContentQueryException(src, innerException: ex);
                }

                var projection = query.Projection;

                if (projection != null)
                {
                    if (!enableProjection)
                    {
                        throw new ApplicationException(String.Format("Projection in top level query is not allowed ({0}:{1})", Parser.SnLucLexer.Keywords.Select, projection));
                    }
                }

                if (skip != 0)
                {
                    query.Skip = skip;
                }

                if (top != 0)
                {
                    query.PageSize = top;
                }
                else
                if (query.PageSize == 0)
                {
                    query.PageSize = GetDefaultMaxResults();
                }

                if (sort != null && sort.Count() > 0)
                {
                    query.SetSort(sort);
                }

                if (enableAutofilters != FilterStatus.Default)
                {
                    query.EnableAutofilters = enableAutofilters;
                }
                if (enableLifespanFilter != FilterStatus.Default)
                {
                    query.EnableLifespanFilter = enableLifespanFilter;
                }

                //Re-set settings values. This is important for NodeList that
                //uses the paging info written into the query text.
                if (settings != null)
                {
                    settings.Top  = query.PageSize;
                    settings.Skip = query.Skip;
                }

                InnerQueryResult result;

                var qresult = query.Execute().ToList();

                if (projection == null || !enableProjection)
                {
                    var idResult = qresult.Select(o => o.NodeId).ToArray();
                    result = new InnerQueryResult {
                        IsIntArray = true, IntArray = idResult, StringArray = idResult.Select(i => i.ToString()).ToArray()
                    };
                }
                else
                {
                    var stringResult = qresult.Select(o => o[projection, false]).Where(r => !String.IsNullOrEmpty(r));
                    var escaped      = new List <string>();
                    foreach (var s in stringResult)
                    {
                        escaped.Add(EscapeForQuery(s));
                    }
                    result = new InnerQueryResult {
                        IsIntArray = false, StringArray = escaped.ToArray()
                    };
                }

                traceInfo = query.TraceInfo;
                count     = query.TotalCount;

                return(result);
            }
Ejemplo n.º 4
0
        private IEnumerable <int> GetIdResultsWithLucQuery(int top, int skip, IEnumerable <SortInfo> sort,
                                                           FilterStatus enableAutofilters, FilterStatus enableLifespanFilter)
        {
            var queryText = Text;

            if (!queryText.Contains("}}"))
            {
                LucQuery query;

                try
                {
                    query = LucQuery.Parse(queryText);
                }
                catch (ParserException ex)
                {
                    throw new InvalidContentQueryException(queryText, innerException: ex);
                }

                if (skip != 0)
                {
                    query.Skip = skip;
                }

                query.Top = System.Math.Min(top == 0 ? int.MaxValue : top, query.Top == 0 ? int.MaxValue : query.Top);
                if (query.Top == 0)
                {
                    query.Top = GetDefaultMaxResults();
                }

                query.PageSize = query.Top;

                if (sort != null && sort.Count() > 0)
                {
                    query.SetSort(sort);
                }

                if (enableAutofilters != FilterStatus.Default)
                {
                    query.EnableAutofilters = enableAutofilters;
                }
                if (enableLifespanFilter != FilterStatus.Default)
                {
                    query.EnableLifespanFilter = enableLifespanFilter;
                }

                //Re-set settings values. This is important for NodeList that
                //uses the paging info written into the query text.
                this.Settings.Top  = query.PageSize;
                this.Settings.Skip = query.Skip;
                //this.Settings.Sort = we don't need this

                this.TraceInfo = new[] { query.TraceInfo };

                var lucObjects = query.Execute().ToList();

                TotalCount = query.TotalCount;

                return((from luco in lucObjects
                        select luco.NodeId).ToList());
            }
            else
            {
                List <string> log;
                int           count;
                IEnumerable <QueryTraceInfo> traceInfo;
                var result = RecursiveExecutor.ExecuteRecursive(queryText, top, skip,
                                                                sort, enableAutofilters, enableLifespanFilter, this.Settings, out count, out log, out traceInfo);

                TotalCount = count;

                this.TraceInfo = traceInfo;

                return(result);
            }
        }