Putting a mapping in an index
In the previous chapter, we saw how to build mapping by indexing documents. This recipe shows how to put a type mapping in an index. This kind of operation can be considered as the Elasticsearch version of an SQL-created table.
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.
To correctly execute the following commands, the index created in the Creating an index recipe is required.
How to do it...
The HTTP method to put a mapping is PUT
(also POST
works). The URL format for putting a mapping is:
http://<server>/<index_name>/<type_name>/_mapping
For putting a mapping in an index, we will perform the steps given as follows:
If we consider the type order of the previous chapter, the call will be as follows:
curl -XPUT 'http://localhost:9200...