Mapping

一、概念

ES中的mapping类似于数据库中的表结构。mapping中包含字段名称、类型、字段使用的分词器、是否评分、是否创建索引等属性

二、查看mapping

GET index/_mapping

三、常用数据类型

数字类型:long、integer、short、byte、double、float等

Keyword:不会被分词,建议id用keyword

Dates:date

Alias:别名

text:文本类型。默认会被创建倒排索引,字段内容会被分词,在生成倒排索引之前,字符串会被拆分成一个一个的词项。

   在使用时,在每一个text类型下都会被默认创建一个keyword类型

nested:嵌套类型

四、映射类型

整数->long     浮点数->float     true||false->boolean     日期->date     数组->取决于数组中第一个有效值     对象->object     字符串->text

 1 #coerce为false表示不允许强制类型转换
 2 PUT coerce
 3 {
 4   "mappings": {
 5     "properties": {
 6       "num_one": {
 7         "type": "integer"
 8       },
 9       "num_two": {
10         "type": "integer",
11         "coerce": false
12       }
13     }
14   }
15 }

 

posted @ 2022-02-09 17:47  showMeTheCodes  阅读(384)  评论(0编辑  收藏  举报