@@ -160,7 +160,7 @@ public void RegisterTemplateIfNeeded()
160160 {
161161 var templateExistsResponse = _client . Indices . TemplateExistsForAll < VoidResponse > ( _templateName , new IndexTemplateExistsRequestParameters ( )
162162 {
163- RequestConfiguration = new RequestConfiguration ( ) { AllowedStatusCodes = new [ ] { 200 , 404 } }
163+ RequestConfiguration = new RequestConfiguration ( ) { AllowedStatusCodes = new [ ] { 200 , 404 } }
164164 } ) ;
165165 if ( templateExistsResponse . HttpStatusCode == 200 )
166166 {
@@ -173,7 +173,7 @@ public void RegisterTemplateIfNeeded()
173173 var result = _client . Indices . PutTemplateForAll < StringResponse > ( _templateName , GetTemplatePostData ( ) ,
174174 new PutIndexTemplateRequestParameters
175175 {
176- IncludeTypeName = IncludeTypeName ? true : ( bool ? ) null
176+ IncludeTypeName = IncludeTypeName ? true : ( bool ? ) null
177177 } ) ;
178178
179179 if ( ! result . Success )
@@ -222,15 +222,15 @@ private object GetTemplateData()
222222 if ( _options . GetTemplateContent != null )
223223 return _options . GetTemplateContent ( ) ;
224224
225- var settings = new Dictionary < string , string >
226- {
227- { "index.refresh_interval" , "5s" }
228- } ;
225+ var settings = _options . TemplateCustomSettings ?? new Dictionary < string , string > ( ) ;
226+
227+ if ( ! settings . ContainsKey ( "index.refresh_interval" ) )
228+ settings . Add ( "index.refresh_interval" , "5s" ) ;
229229
230- if ( _options . NumberOfShards . HasValue )
230+ if ( _options . NumberOfShards . HasValue && ! settings . ContainsKey ( "number_of_shards" ) )
231231 settings . Add ( "number_of_shards" , _options . NumberOfShards . Value . ToString ( ) ) ;
232232
233- if ( _options . NumberOfReplicas . HasValue )
233+ if ( _options . NumberOfReplicas . HasValue && ! settings . ContainsKey ( "number_of_replicas" ) )
234234 settings . Add ( "number_of_replicas" , _options . NumberOfReplicas . Value . ToString ( ) ) ;
235235
236236 return ElasticsearchTemplateProvider . GetTemplate (
@@ -245,14 +245,14 @@ private object GetTemplateData()
245245 public void DiscoverClusterVersion ( )
246246 {
247247 if ( ! _options . DetectElasticsearchVersion ) return ;
248-
248+
249249 var response = _client . Cat . Nodes < StringResponse > ( new CatNodesRequestParameters ( )
250- {
251- Headers = new [ ] { "v" }
250+ {
251+ Headers = new [ ] { "v" }
252252 } ) ;
253253 if ( ! response . Success ) return ;
254254
255- _discoveredVersion = response . Body . Split ( new [ ] { '\r ' , '\n ' } , StringSplitOptions . RemoveEmptyEntries )
255+ _discoveredVersion = response . Body . Split ( new [ ] { '\r ' , '\n ' } , StringSplitOptions . RemoveEmptyEntries )
256256 . FirstOrDefault ( ) ;
257257
258258 if ( _discoveredVersion ? . StartsWith ( "7." ) ?? false )
0 commit comments