Exemple #1
0
        public void OrWithOrWithTrueOptimizesToTrue()
        {
            var exists1  = new ExistsCriteria("1");
            var exists2  = new ExistsCriteria("2");
            var criteria = OrCriteria.Combine(exists1, OrCriteria.Combine(ConstantCriteria.True, exists2));

            var actual = ConstantCriteriaFilterReducer.Reduce(criteria);

            Assert.Same(ConstantCriteria.True, actual);
        }
Exemple #2
0
        public void AndWithFalseOptimizesToFalse()
        {
            var exists1  = new ExistsCriteria("1");
            var exists2  = new ExistsCriteria("2");
            var criteria = AndCriteria.Combine(exists1, ConstantCriteria.False, exists2);

            var actual = ConstantCriteriaFilterReducer.Reduce(criteria);

            Assert.Same(ConstantCriteria.False, actual);
        }
        ElasticTranslateResult Translate(Expression e)
        {
            var evaluated = PartialEvaluator.Evaluate(e);

            CompleteHitTranslation(evaluated);

            searchRequest.Query = ConstantCriteriaFilterReducer.Reduce(searchRequest.Query);
            ApplyTypeSelectionCriteria();

            return(new ElasticTranslateResult(searchRequest, materializer));
        }
Exemple #4
0
        public void AndWithTrueRemovesTrue()
        {
            var exists1  = new ExistsCriteria("1");
            var exists2  = new ExistsCriteria("2");
            var criteria = AndCriteria.Combine(exists1, ConstantCriteria.True, exists2);

            var actual = ConstantCriteriaFilterReducer.Reduce(criteria);

            var andActual = Assert.IsType <AndCriteria>(actual);

            Assert.DoesNotContain(andActual.Criteria, c => c == ConstantCriteria.True);
            Assert.Single(andActual.Criteria, exists1);
            Assert.Single(andActual.Criteria, exists2);
        }
Exemple #5
0
        public void OrWithFalseRemovesFalse()
        {
            var exists1  = new ExistsCriteria("1");
            var exists2  = new ExistsCriteria("2");
            var criteria = OrCriteria.Combine(exists1, ConstantCriteria.False, exists2);

            var actual = ConstantCriteriaFilterReducer.Reduce(criteria);

            var orActual = Assert.IsType <OrCriteria>(actual);

            Assert.DoesNotContain(orActual.Criteria, c => c == ConstantCriteria.False);
            Assert.Single(orActual.Criteria, exists1);
            Assert.Single(orActual.Criteria, exists2);
        }
Exemple #6
0
        ElasticTranslateResult Translate(Expression e)
        {
            var evaluated  = PartialEvaluator.Evaluate(e);
            var aggregated = FacetExpressionVisitor.Rebind(Mapping, SourceType, evaluated);

            if (aggregated.Collected.Count > 0)
            {
                this.CompleteFacetTranslation(aggregated);
            }
            else
            {
                this.CompleteHitTranslation(evaluated);
            }

            this.searchRequest.Query  = QueryCriteriaRewriter.Compensate(this.searchRequest.Query);
            this.searchRequest.Filter = ConstantCriteriaFilterReducer.Reduce(this.searchRequest.Filter);
            this.ApplyTypeSelectionCriteria();

            return(new ElasticTranslateResult(this.searchRequest, this.materializer));
        }
Exemple #7
0
        public void TopLevelFalseRemainsFalse()
        {
            var actual = ConstantCriteriaFilterReducer.Reduce(ConstantCriteria.False);

            Assert.Same(ConstantCriteria.False, actual);
        }
Exemple #8
0
        public void TrueRemainsTrue()
        {
            var actual = ConstantCriteriaFilterReducer.Reduce(ConstantCriteria.True);

            Assert.Same(ConstantCriteria.True, actual);
        }