Before we start adding any documents to Elasticsearch, we need to create an index first. An index in Elasticsearch is basically a named space where you can ingest data. Elasticsearch supports multiple indexes, handling right out of the box. We will take advantage of it by creating our own index for our exercise.
Run the following command to start a new index by using the HTTP PUT method:
curl -XPUT 'http://localhost:9200/news/'
This command should return the following:
{"acknowledged":true}
If the index already exists (for example, run the above command twice), you will see the following error message:
{"error":"IndexAlreadyExistsException[[news] already exists]","status":400}
To confirm the index is created, we can use the GET method:
curl -XGET 'http://localhost:9200/news/'
This should return the following:
{ news: { aliases: { }, mappings: { }, settings: { index: { creation_date: "1425700268502", number_of_shards: "5", ...