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); }
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)); }
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); }
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); }
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)); }
public void TopLevelFalseRemainsFalse() { var actual = ConstantCriteriaFilterReducer.Reduce(ConstantCriteria.False); Assert.Same(ConstantCriteria.False, actual); }
public void TrueRemainsTrue() { var actual = ConstantCriteriaFilterReducer.Reduce(ConstantCriteria.True); Assert.Same(ConstantCriteria.True, actual); }