获取索引分片计数

时间:2018-03-25 01:08:29

标签: elasticsearch nest elasticsearch-net

我需要使用Nest(或Elastic.Net,无关紧要)在C#中获取特定索引的主分片数。我应该使用哪种API调用?

  1. IndicesShardStores
  2. CatShards
  3. GetIndexSettings
  4. 或其他什么?

    这是正确的,也是表现最好的方式吗?

    var settings = client.GetIndexSettings(i => i.Index(sourceIndexName));
    settings.Indices[sourceIndexName].Settings.NumberOfShards
    

1 个答案:

答案 0 :(得分:1)

如果您只想计算给定索引的主分片数,那么GetIndexSettings()是最佳选择。您列出的其他选项会返回比您需要的更多信息。

相关问题