public IEnumerable <int> Execute(string lucQuery) { var query = LucQuery.Parse(lucQuery); var lucObjects = query.Execute(); return(from lucObject in lucObjects select lucObject.NodeId); }
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); }
private IEnumerable <int> GetIdResultsWithLucQuery(int top, int skip, IEnumerable <SortInfo> sort, FilterStatus enableAutofilters, FilterStatus enableLifespanFilter, QueryExecutionMode executionMode) { 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; } if (executionMode != QueryExecutionMode.Default) { query.QueryExecutionMode = executionMode; } // 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; var lucObjects = query.Execute().ToList(); TotalCount = query.TotalCount; return((from luco in lucObjects select luco.NodeId).ToList()); } else { List <string> log; int count; var result = RecursiveExecutor.ExecuteRecursive(queryText, top, skip, sort, enableAutofilters, enableLifespanFilter, executionMode, this.Settings, out count, out log); TotalCount = count; return(result); } }
private static InnerQueryResult ExecuteInnerScript(string src, int top, int skip, IEnumerable <SortInfo> sort, FilterStatus enableAutofilters, FilterStatus enableLifespanFilter, QueryExecutionMode executionMode, QuerySettings settings, bool enableProjection, out int count) { 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)); } query.ForceLuceneExecution = true; } 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; } if (executionMode != QueryExecutionMode.Default) { query.QueryExecutionMode = executionMode; } // 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() }; } count = query.TotalCount; return(result); }
private IEnumerable <int> GetIdResultsWithLucQuery(int top, int skip, IEnumerable <SortInfo> sort, bool?enableAutofilters, bool?enableLifespanFilter) { var queryText = Text; if (!queryText.Contains("}}")) { var query = LucQuery.Parse(queryText); 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.HasValue) { query.EnableAutofilters = enableAutofilters.Value; } if (enableLifespanFilter.HasValue) { query.EnableLifespanFilter = enableLifespanFilter.Value; } //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); } }