Closed braveyp closed 2 months ago
The GetIndicesSettingResponse class seems to be missing the Indices property, ie:
[System.Text.Json.Serialization.JsonIgnore]
public IReadOnlyDictionary<IndexName, IndexState> Indices => BackingDictionary;
I ended up using a workaround just to get the settings I need:
public class PartialSettingsState
{
[JsonPropertyName("settings")]
public PartialSettings Settings { get; set; }
}
public class PartialSettings
{
[JsonPropertyName("index")]
public PartialIndexSettings Index { get; set; }
}
public class PartialIndexSettings
{
[JsonPropertyName("number_of_replicas")]
public int? NumberOfReplicas { get; set; }
[JsonPropertyName("refresh_interval")]
public Duration? RefreshInterval { get; set; }
}
[TestClass]
public class GetSettingsWorkaround
{
[TestMethod]
public async Task GetSettings()
{
var indexName = "test";
var client = TestHelper.GetClient();
var response = await client.Transport.RequestAsync<StringResponse>(HttpMethod.GET,
$"{indexName}/_settings/index.number_of_replicas,index.refresh_interval");
var options = new JsonSerializerOptions()
{
NumberHandling = JsonNumberHandling.AllowReadingFromString
};
IReadOnlyDictionary<IndexName, PartialSettingsState> indices =
JsonSerializer.Deserialize<Dictionary<IndexName, PartialSettingsState>>(response.Body, options);
var settings = indices[indexName].Settings;
}
}
Yes, it seems like the public accessor is missing. This should hopefully be an easy fix 🙁
Elastic.Clients.Elasticsearch version: 8.15.6
Elasticsearch version: 8.15.0
.NET runtime version: 4.8
Operating system version: Windows 11
Description of the problem including expected versus actual behavior:
GetIndicesSettingsReponse puts the settings into a protected dictionary but doesn't provide a public method to actually access those settings.
Steps to reproduce:
Expected behavior I would expect a call to get the settings for an index would return the settings, ideally in a typed IndexSettings object.