Esempio n. 1
0
        public IEnumerable <LucObject> Execute(bool allVersions)
        {
            if (LucQuery.IsAutofilterEnabled(this.EnableAutofilters) || LucQuery.IsLifespanFilterEnabled(this.EnableLifespanFilter))
            {
                var fullQuery = new BooleanQuery();
                fullQuery.Add(new BooleanClause(this.Query, BooleanClause.Occur.MUST));

                if (LucQuery.IsAutofilterEnabled(this.EnableAutofilters))
                {
                    fullQuery.Add(new BooleanClause(this.AutoFilterQuery, BooleanClause.Occur.MUST));
                }
                if (LucQuery.IsLifespanFilterEnabled(this.EnableLifespanFilter) && this.LifespanQuery != null)
                {
                    fullQuery.Add(new BooleanClause(this.LifespanQuery, BooleanClause.Occur.MUST));
                }

                this.Query = fullQuery;
            }

            using (var op = SnTrace.Query.StartOperation("LucQuery: {0}", this))
            {
                if (FieldLevel == QueryFieldLevel.NotDefined)
                {
                    FieldLevel = GetFieldLevel();
                }
                var permissionChecker = new PermissionChecker(this.User ?? AccessProvider.Current.GetCurrentUser(), FieldLevel, allVersions);

                this.QueryInfo = QueryClassifier.Classify(this, this.Top, this.Skip, this.SortFields, this.CountOnly, allVersions);

                IEnumerable <LucObject> result   = null;
                IQueryExecutor          executor = null;

                var executionAlgorithm = ForceLuceneExecution
                    ? ContentQueryExecutionAlgorithm.LuceneOnly
                    : Configuration.Querying.ContentQueryExecutionAlgorithm;

                switch (executionAlgorithm)
                {
                default:
                case ContentQueryExecutionAlgorithm.Default:
                case ContentQueryExecutionAlgorithm.Provider:
                {
                    executor = SearchProvider.GetExecutor(this);
                    executor.Initialize(this, permissionChecker);
                    result = Execute(executor);
                }
                break;

                case ContentQueryExecutionAlgorithm.LuceneOnly:
                {
                    executor = SearchProvider.GetFallbackExecutor(this);
                    executor.Initialize(this, permissionChecker);
                    result = Execute(executor);
                }
                break;

                case ContentQueryExecutionAlgorithm.Validation:
                {
                    executor = SearchProvider.GetExecutor(this);
                    executor.Initialize(this, permissionChecker);
                    result = Execute(executor);
                    if (!(executor is LuceneQueryExecutor))
                    {
                        var fallbackExecutor = SearchProvider.GetFallbackExecutor(this);
                        fallbackExecutor.Initialize(this, permissionChecker);
                        var expectedResult = Execute(fallbackExecutor);
                        AssertResultsAreEqual(expectedResult, result, fallbackExecutor.QueryString, executor.QueryString);
                    }
                }
                break;
                }

                op.Successful = true;
                return(result);
            }
        }
Esempio n. 2
0
 public void Initialize(LucQuery lucQuery, PermissionChecker permissionChecker)
 {
     this.LucQuery          = lucQuery;
     this.PermissionChecker = permissionChecker;
 }