From 4131406abdd5e1d5bac9931d133609c856531147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96rjan=20Sj=C3=B6holm?= Date: Mon, 14 Sep 2020 13:24:05 +0200 Subject: [PATCH] Don't overwrite TypeName if it has been set to null In order to be able to use templates and at the same time remove the doc type we shouldn't override it if it's set to null. --- .../Sinks/ElasticSearch/ElasticsearchSinkState.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticsearchSinkState.cs b/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticsearchSinkState.cs index a605ea0b..a1560c9f 100644 --- a/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticsearchSinkState.cs +++ b/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticsearchSinkState.cs @@ -69,8 +69,8 @@ private ElasticsearchSinkState(ElasticsearchSinkOptions options) if (string.IsNullOrWhiteSpace(options.IndexFormat)) throw new ArgumentException("options.IndexFormat"); if (string.IsNullOrWhiteSpace(options.TemplateName)) throw new ArgumentException("options.TemplateName"); - // Strip type argument if ESv7 since multiple types are not supported anymore - if (options.AutoRegisterTemplateVersion == AutoRegisterTemplateVersion.ESv7) + // Since TypeName is deprecated we shouldn't set it, if has been deliberately set to null. + if (options.TypeName == null && options.AutoRegisterTemplateVersion == AutoRegisterTemplateVersion.ESv7) { options.TypeName = "_doc"; }