Creating an index
The first operation to do before starting indexing data in Elasticsearch is to create an index--the main container of our data.
An index is similar to the concept of a database in SQL, a container for types (tables in SQL) and documents (records in SQL).
Getting ready
You need an up-and-running Elasticsearch installation, as used in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
To execute curl
via the command line, you need to install curl
for your operative system.
How to do it...
The HTTP method to create an index is PUT
(but also POST
works); the REST URL contains the index name:
http://<server>/<index_name>
For creating an index, we will perform the following steps:
From the command line, we can execute a
PUT
call:curl -XPUT http://127.0.0.1:9200/myindex -d '{ "settings" : { "index" : { "number_of_shards" : 2, "number_of_replicas...