コード例 #1
0
        /// <summary>
        /// Compiles an <see cref="SnQuery"/> to <see cref="LucQuery"/>.
        /// </summary>
        public LucQuery Compile(SnQuery snQuery, IQueryContext context)
        {
            var visitor = new SnQueryToLucQueryVisitor(_masterAnalyzer, context);

            visitor.Visit(snQuery.QueryTree);

            var searchManager = ((ILuceneIndexingEngine)IndexManager.IndexingEngine).LuceneSearchManager;

            return(LucQuery.Create(visitor.Result, searchManager));
        }
コード例 #2
0
        private LucQuery Compile(SnQuery query, IQueryContext context)
        {
            var indexingEngine = (Lucene29LocalIndexingEngine)IndexManager.IndexingEngine;
            var analyzer       = indexingEngine.GetAnalyzer();
            var visitor        = new SnQueryToLucQueryVisitor(analyzer, context);

            visitor.Visit(query.QueryTree);

            var result = LucQuery.Create(visitor.Result, indexingEngine.LuceneSearchManager);

            result.Skip                 = query.Skip;
            result.Top                  = query.Top;
            result.SortFields           = query.Sort?.Select(s => CreateSortField(s.FieldName, s.Reverse)).ToArray() ?? new SortField[0];
            result.EnableAutofilters    = query.EnableAutofilters;
            result.EnableLifespanFilter = query.EnableLifespanFilter;
            result.QueryExecutionMode   = query.QueryExecutionMode;
            result.CountOnly            = query.CountOnly;
            result.CountAllPages        = query.CountAllPages;

            return(result);
        }