I need to list all the indexes and types in Elasticsearch.
Basically I use _client.stats().Indices
to acquire the indexes, and filter using foreach
excluded index list like this:
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;
}
Is this right way to do to list all the indexes from Elasticsearch or is there a better way?