internal static FacetRebindCollectionResult Rebind(IElasticMapping mapping, Type sourceType, Expression expression)
        {
            Argument.CheckNotNull("mapping", mapping);
            Argument.CheckNotNull("expression", expression);

            var visitor           = new FacetExpressionVisitor(mapping, sourceType);
            var visitedExpression = visitor.Visit(expression);
            var facets            = new HashSet <IFacet>(visitor.GetFacets());
            var materializer      = GetFacetMaterializer(visitor.selectProjection, visitor.groupBy);

            return(new FacetRebindCollectionResult(visitedExpression, facets, visitor.bindingParameter, materializer));
        }
示例#2
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));
        }