/// <summary> /// Based on the type information present in this descriptor create method that takes /// the returned _source and hit and returns the ClrType it should deserialize too. /// This is so that Documents[A] can contain actual instances of subclasses B, C as well. /// If you specify types using .Types(typeof(B), typeof(C)) then NEST can automagically /// create a TypeSelector based on the hits _type property. /// </summary> public static void CloseOverAutomagicCovariantResultSelector(Inferrer infer, ICovariantSearchRequest self) { if (infer == null || self == null) return; var returnType = self.ClrType; if (returnType == null) return; var types = self.ElasticsearchTypes?.Match(all => new TypeName[] { "_all" }, many => many.Types); types = (types ?? Enumerable.Empty<TypeName>()).Where(t => t.Type != null).ToList(); if (self.TypeSelector != null || !types.HasAny(t => t.Type != returnType)) return; var typeDictionary = types.ToDictionary(infer.TypeName, t => t.Type); self.TypeSelector = (o, h) => { Type t; return !typeDictionary.TryGetValue(h.Type, out t) ? returnType : t; }; }
public DslPrettyPrintVisitor(IConnectionSettingsValues settings) { this._sb = new StringBuilder(); this._infer = settings.Inferrer; }
protected override Id GetIdForOperation(Inferrer inferrer) => Self.Id ?? new Id(Self.Document);
protected override Routing GetRoutingForOperation(Inferrer inferrer) => Self.Routing ?? new Routing(Self.Document);
public static string NestedProperty <TRoot, TProperty>(this Inferrer inferrer, Expression <Func <TRoot, object> > rootExpression, Expression <Func <TProperty, object> > propExpression) { return($"{inferrer.PropertyName(rootExpression)}.{inferrer.PropertyName(propExpression)}"); }
public static ElasticMappingResolver Create(Func <ITypeMapping> getMapping, Inferrer inferrer, ILogger logger = null) { return(new ElasticMappingResolver(getMapping, inferrer, logger: logger)); }
public static ElasticMappingResolver Create <T>(Func <TypeMappingDescriptor <T>, ITypeMapping> mappingBuilder, Inferrer inferrer, Func <ITypeMapping> getMapping, ILogger logger = null) where T : class { var codeMapping = new TypeMappingDescriptor <T>(); codeMapping = mappingBuilder(codeMapping) as TypeMappingDescriptor <T>; return(new ElasticMappingResolver(codeMapping, inferrer, getMapping, logger: logger)); }
public ElasticMappingResolver(ITypeMapping codeMapping, Inferrer inferrer, Func <ITypeMapping> getMapping, ILogger logger = null) : this(getMapping, inferrer, logger) { _codeMapping = codeMapping; }
public ElasticMappingResolver(Func <ITypeMapping> getMapping, Inferrer inferrer = null, ILogger logger = null) { GetServerMappingFunc = getMapping; _inferrer = inferrer; _logger = logger ?? NullLogger.Instance; }