Search code examples
nestelasticsearch.net

Elasticsearch.NET version 7 - How to Check If Index Exists


In Elasticsearch.NET 6.x, it is possible to check if index exists using IElasticClient method:

    bool exists = elasticClient.IndexExists("my-index-name").Exists;

Method is removed in Elasticsearch.NET version 7.


Solution

  • In Elasticsearch.NET version 7 methods related to indices operations are moved into IndicesNamespace, so IndexExists method has been moved to:

        bool exists = elasticClient.Indices.Exists("my-index-name").Exists;
    

    Similarly, different methods have been moved to:

    • Cat
    • Cluster
    • Graph
    • Sql
    • Nodes
    • etc...