- Elasticsearch 7.0 Cookbook(Fourth Edition)
- Alberto Paro
- 120字
- 2021-06-24 14:52:16
There's more...
The create index command also allows for the passing of the mappings section, which contains the mapping definitions. It is a shortcut for creating an index with mappings without executing an extra PUT mapping call.
A common example of this call, using the mapping from the Putting a mapping in an index recipe, is as follows:
PUT /myindex
{
"settings": {
"number_of_shards": 2,
"number_of_replicas": 1
},
"mappings": {
"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": true
}
}
}
}