/// <summary> /// Gets the index settings for the specified index /// </summary> public IndexSettingsResponse GetIndexSettings(string index) { string path = this.CreatePath(index) + "_settings"; var status = this.Connection.GetSync(path); var response = new IndexSettingsResponse(); response.IsValid = false; try { var o = JObject.Parse(status.Result); var settingsObject = o.First.First.First.First; var settings = JsonConvert .DeserializeObject <IndexSettings>(settingsObject.ToString()); foreach (JProperty s in settingsObject.Children <JProperty>()) { settings.Add(StripIndex.Replace(s.Name, ""), s.Value.ToString()); } response.Settings = settings; response.IsValid = true; } catch { } response.ConnectionStatus = status; return(response); }
/// <summary> /// Gets the index settings for the specified index /// </summary> public IIndexSettingsResponse GetIndexSettings(string index) { string path = this.PathResolver.CreateIndexPath(index, "_settings"); var status = this.Connection.GetSync(path); var response = new IndexSettingsResponse(); response.IsValid = false; try { var o = JObject.Parse(status.Result); var settingsObject = o.First.First.First.First; var settingsContainer = new JObject(); // In indexsettings response all analyzers etc are delivered as settings so need to split up the settings key and make proper json foreach (JProperty s in settingsObject.Children <JProperty>()) { var name = StripIndex.Replace(s.Name, ""); if (name.StartsWith("analysis.")) { var keys = name.Split('.'); RewriteIndexSettingsResponseToIndexSettingsJSon(settingsContainer, keys, s.Value); } else if (name.StartsWith("similarity.")) { var keys = name.Split('.'); var similaryKeys = new[] { keys[0], keys[1], string.Join(".", keys.Skip(2).ToArray()) }; RewriteIndexSettingsResponseToIndexSettingsJSon(settingsContainer, similaryKeys, s.Value); } else { RewriteIndexSettingsResponseToIndexSettingsJSon(settingsContainer, new[] { name }, s.Value); } } response.Settings = this.Deserialize <IndexSettings>(settingsContainer); response.IsValid = true; } catch { } response.ConnectionStatus = status; return(response); }