public static bool IfIndexOrTypeExists(string indexName, ElasticConnection connection) { try { connection.Head(new IndexExistsCommand(indexName)); return(true); } catch (OperationException ex) { if (ex.HttpStatusCode == 404) { return(false); } throw; } }