如何在NEST v7.x中获取索引设置

问题描述 投票:0回答:1

在以前的NEST / Elasticsearch.Net(v5.x)版本中,我们可以使用下面的代码来获取索引设置。

Client.LowLevel.IndicesGetSettings<JObject>(currentIndexName)

但是,这些方法似乎已在v7.X中删除。 V7.x中的等效功能是什么?

在Java方面,有一个Get Settings API,其中包含一些适当的文档。我没有在NEST上看到类似的内容。

https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-get-settings.html

[如果有人知道等效的api和/或任何可用的文档,请告诉我。

谢谢!

nest elasticsearch.net
1个回答
0
投票
这里是一个简单的应用程序:

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

希望有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.