English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Mappings are the outline of documents stored in the index. It defines data types such as geo_point or string, as well as the format and rules of the fields displayed in the document, to control the mapping of dynamically added fields.
PUT bankaccountdetails { "mappings": { "properties": { "name": { "type": "text"}, "date": { "type": "date"}, "balance": { "type": "double"}, "liability": { "type": "double"} } } }
When we run the above code, we get the following response-
{ "acknowledged": true, "shards_acknowledged": true, "index": "bankaccountdetails" }
Elasticsearch supports a variety of different data types for fields in documents. This section discusses the data types used to store fields in Elasticsearch in detail.
These are basic data types, such as text, keywords, dates, long integers, double precision, boolean, or IP, which are supported by almost all systems.
These data types are combinations of core data types. These include arrays, JSON objects, and nested data types. An example of nested data types is shown as follows &minus
POST /tabletennis/_doc/1 { "group": "players", { } { "first": "kevin", \ } ] }
When we run the above code, we get the following response-
{ "_index": "tabletennis", "_type": "_doc", "_id": "1", _version": 2, "result": "updated", "_shards": { "total": 2, "successful": 1, "failed": 0 } "_seq_no": 1, "_primary_term": 1 }
Another example code is shown as follows-
POST /accountdetails/_doc/1 { "from_acc":7056443341", "to_acc":7032460534", "date": "11/1/2016", "amount":10000 }
When we run the above code, we get the following response-
{ "_index": "accountdetails", "_type": "_doc", "_id": "1", "_version": 1, "result": "created", "_shards": { "total": 2, "successful": 1, "failed": 0 } "_seq_no": 1, "_primary_term": 1 }
We can use the following command to check the above documents-
GET /accountdetails/_mappings?include_type_name=false
In Elasticsearch 7indexes created in .0.0 or higher versions no longer accept the _default_ mapping. Indexes created6.x will continue to work in Elasticsearch 6The .x still works as before. In7The deprecated types in the .0 API.