public void CreateIndex <T>(string indexName) where T : class { if (!_client.IndexExists(indexName, string.Empty)) { var response = _client.CreateIndex( indexName, i => i .Settings(settings => settings .NumberOfShards(_settings.IndexShards) .NumberOfReplicas(_settings.IndexReplicas) ) .Mappings(ms => ms .Map <T>(m => m .AutoMap() .Properties(p => p))) , string.Empty); if (response.HttpStatusCode != (int)HttpStatusCode.OK) { throw new Exception( $"Call to ElasticSearch client Received non-200 response when trying to create the Index {nameof(indexName)}, Status Code:{response.HttpStatusCode ?? -1}\r\n{response.DebugInformation}", response.OriginalException); } } }