小编cao*_*ish的帖子

如何在C#中使用Nest获取所有索引并过滤索引

我需要列出 Elasticsearch 中的所有索引和类型。

基本上我_client.stats().Indices用来获取索引,并使用foreach排除的索引列表进行过滤,如下所示:

public Dictionary<string, Stats> AllIndexes()
{
    _client = new ElasticClient(setting);
    var result = _client.Stats();
    var allIndex = result.Indices;
    var excludedIndexList = ExcludedIndexList();
    foreach (var index in excludedIndexList)
    {
        if (allIndex.ContainsKey(index)) allIndex.Remove(index);
    }

    return allIndex;
}
Run Code Online (Sandbox Code Playgroud)

这是从 Elasticsearch 列出所有索引的正确方法还是有更好的方法?

.net c# elasticsearch nest

6
推荐指数
2
解决办法
9697
查看次数

标签 统计

.net ×1

c# ×1

elasticsearch ×1

nest ×1