public void UseQueryParser <T>(IndexTypeBase <T> indexType, Action <ElasticQueryParserConfiguration> configure = null) where T : class { UseQueryParser(c => { c.UseMappings <T>(indexType.BuildMapping, () => indexType.Configuration.Client.GetMapping(new GetMappingRequest(indexType.Index.Name, indexType.Name)).Mapping); c.UseNested(); configure?.Invoke(c); }); }
public static ElasticQueryParserConfiguration UseMappings <T>(this ElasticQueryParserConfiguration config, IndexTypeBase <T> indexType) where T : class { var logger = indexType.Configuration.LoggerFactory.CreateLogger(typeof(ElasticQueryParserConfiguration)); var descriptor = indexType.BuildMapping(new TypeMappingDescriptor <T>()); return(config .UseAliases(indexType.AliasMap) .UseMappings <T>(d => descriptor, () => { var response = indexType.Configuration.Client.GetMapping(new GetMappingRequest(indexType.Index.Name, indexType.Name)); if (response.IsValid) { logger.LogTraceRequest(response); } else { logger.LogErrorRequest(response, "Error getting mapping for index {Name}", indexType.Index.Name); } return (ITypeMapping)response.Mapping ?? descriptor; })); }
public static ElasticQueryParserConfiguration UseMappings <T>(this ElasticQueryParserConfiguration config, IndexTypeBase <T> indexType) where T : class { var logger = indexType.Configuration.LoggerFactory.CreateLogger(typeof(ElasticQueryParserConfiguration)); var descriptor = indexType.BuildMapping(new TypeMappingDescriptor <T>()); return(config .UseAliases(indexType.AliasMap) .UseMappings <T>(d => descriptor, () => { var response = indexType.Configuration.Client.GetMapping(new GetMappingRequest(indexType.Index.Name, indexType.Name)); logger.Trace(() => response.GetRequest()); if (!response.IsValid) { logger.Error(response.OriginalException, response.GetErrorMessage()); } return (ITypeMapping)response.Mapping ?? descriptor; })); }