写点什么

Elasticsearch dynamic mapping

用户头像
escray
关注
发布于: 2021 年 02 月 15 日
Elasticsearch dynamic mapping

Elasticsearch dynamic mapping,文字内容来自 B 站中华石杉 Elasticsearch 高手进阶课程,英文内容来自官方文档。

核心的数据类型


  • string

  • byte,short,integer,long

  • float,double

  • boolean

  • date

Dynamic mapping



The automatic detection and addition of new fields is called dynamic mapping.



Date detection


PUT data/_doc/2{  "create_date": "2015/09/02"}
GET data/_mapping
PUT date_detection_false{ "mappings": { "date_detection": false }}
PUT date_detection_false/_doc/1{ "create": "2015/09/02"}
GET date_detection_false/_mapping
DELETE date_custom
PUT date_custom{ "mappings": { "dynamic_date_formats": ["MM/dd/yyyy"] }}
PUT date_custom/_doc/1{ "create_date": "09/25/2015"}
复制代码


Numeric detection


PUT numeric_detection{  "mappings": {    "numeric_detection": true  }}
PUT numeric_detection/_doc/1{ "my_float": "1.0", // float "my_integer": "1" // long}
GET numeric_detection/_mapping
复制代码
Explicit mapping


Explicit mapping allows you to precisely choose how to define the mapping definition, such as :


  • which string fields should be treated as full text fields

  • which fields contain numbers, dates, or geolocations

  • The format of date values

  • Custom rules to control the mapping for dynamically added fields.

Mapping explosion


Defining too many fields in an index can lead to a mapping explosion, which can cause out of memory errors and difficult situations to recover from.


Use the mapping limit settings to limit the number of field mappings (created manually or dynamically) and prevent documents from causing a mapping explosion.

查看 mapping


GET /index/_mapping/type
复制代码


发布于: 2021 年 02 月 15 日阅读数: 21
用户头像

escray

关注

Let's Go 2017.11.19 加入

在学 Elasticsearch 的项目经理

评论

发布
暂无评论
Elasticsearch dynamic mapping