在以前的NEST / Elasticsearch.Net(v5.x)版本中,我们可以使用下面的代码来获取索引设置。
Client.LowLevel.IndicesGetSettings<JObject>(currentIndexName)
但是,这些方法似乎已在v7.X中删除。 V7.x中的等效功能是什么?
在Java方面,有一个Get Settings API,其中包含一些适当的文档。我没有在NEST上看到类似的内容。
[如果有人知道等效的api和/或任何可用的文档,请告诉我。
谢谢!
class Program
{
static async Task Main(string[] args)
{
var connectionPool = new SniffingConnectionPool(new[] {new Uri("http://localhost:9200")});
var settings = new ConnectionSettings(connectionPool)
.DefaultIndex("index_name")
.EnableDebugMode()
.DisableDirectStreaming()
.PrettyJson();
var client = new ElasticClient(settings);
await client.Indices.DeleteAsync("index_name");
await client.Indices.CreateAsync("index_name", d => d.Settings(s => s.NumberOfShards(20)));
var getIndexSettingsResponse = await client.Indices.GetSettingsAsync("index_name");
Console.WriteLine(getIndexSettingsResponse.Indices["index_name"].Settings.NumberOfShards);
}
}
输出:
20
希望有所帮助。