public Dictionary<string, TemplateSetting> GetTemplate(string templateName) { Contract.Assert(!string.IsNullOrEmpty(templateName)); string url = "/_template/{0}".Fill(templateName); RestResponse result = _provider.Get(url); if (result.Body != null) { var document = new Document(); document.JsonString = result.GetBody(); try { return JsonSerializer.Get<Dictionary<string, TemplateSetting>>(result.GetBody()); } catch (System.Exception e) { _logger.Error(e); } } return null; }
public Document Get(string index, string type, string indexKey, string routing = null) { Contract.Assert(!string.IsNullOrEmpty(index)); Contract.Assert(!string.IsNullOrEmpty(type)); Contract.Assert(!string.IsNullOrEmpty(indexKey)); string url = "/{0}/{1}/{2}".Fill(index.ToLower(), type, indexKey); if (!string.IsNullOrEmpty(routing)) { url = url + string.Format("?routing={0}", routing); } RestResponse result = _provider.Get(url); if (result.Body != null&&(int)result.Status<400) { var document = new Document(); document.JsonString = result.GetBody(); try { var hitResult = JsonSerializer.Get<Hits>(result.GetBody()); document.Hits = hitResult; } catch (System.Exception e) { _logger.Error(e); } return document; } return null; }