- Elasticsearch 7.0 Cookbook(Fourth Edition)
- Alberto Paro
- 133字
- 2021-06-24 14:52:18
How to do it...
The HTTP method to put a mapping is PUT (POST also works). The URL format for putting a mapping is as follows:
http://<server>/<index_name>/_mapping
To put a mapping in an index, we will perform the following steps:
- If we consider a possible order data model to be used as a mapping, the call will be as follows:
PUT /myindex/_mapping
{
"properties": {
"id": {
"type": "keyword",
"store": true
},
"date": {
"type": "date",
"store": false
},
"customer_id": {
"type": "keyword",
"store": true
},
"sent": {
"type": "boolean"
},
"name": {
"type": "text"
},
"quantity": {
"type": "integer"
},
"vat": {
"type": "double",
"index": false
}
}
}
- In the case of a success, the result returned by Elasticsearch should be like this:
{
"acknowledged" : true
}