Skip to content

Instantly share code, notes, and snippets.

@mattcanty
Created November 19, 2014 12:13
Show Gist options
  • Select an option

  • Save mattcanty/504a035be5ec54a64a45 to your computer and use it in GitHub Desktop.

Select an option

Save mattcanty/504a035be5ec54a64a45 to your computer and use it in GitHub Desktop.
Check whether an index exists in Elasticsearch
public bool IndexExists(string index)
{
try
{
Connection.Head(new IndexExistsCommand(index));
return true;
}
catch (OperationException ex)
{
if (ex.HttpStatusCode == 404)
return false;
throw;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment