Checking whether an index exists
A common pitfall error is to query for indices that don't exist. To prevent this issue, Elasticsearch allows you to check for an index's existence.
This check is often used during application startup to create indices that are required for the application to work correctly.
Getting ready
You will need an up-and-running Elasticsearch installation, as we described in the Downloading and installing Elasticsearch recipe of Chapter 1, Getting Started.
To execute the commands in this recipe, you can use any HTTP clients, such as curl (https://curl.haxx.se/), Postman (https://www.getpostman.com/), or others. I suggest using the Kibana console as it provides code completion and better character escaping for Elasticsearch.
To execute the following commands correctly, please use the index we created in the Creating an index recipe.
How to do it...
The HTTP method for checking an index's existence is HEAD
.
The URL format...