概述
分类 | 类型 |
---|---|
字符串类型 | text,keyword |
整数类型 | integer,long,short,byte |
浮点类型 | double,float,half_float,scaled_float |
逻辑类型 | boolean |
日期类型 | date |
范围类型 | integer_range, float_range, long_range, double_range, date_range |
二进制类型 | binary |
数组类型 | array |
对象类型 | object |
嵌套类型 | nested |
地理坐标类型 | geo_point |
地理地图 | geo_shape |
IP类型 | ip |
范围类型 | completion |
令牌计数类型 | token_count |
附件类型 | attachment |
抽取类型 | percolator |
字符串类型
-
text
设置为text类型的字段将会被全文索引,该字段的内容将会被es分词,该字段不可用于排序,很少用于聚合
-
keyword
设置为keyword类型的字段将会被全文索引,该字段的内容将会被es分词,该字段可用于过滤,排序,聚合,该字段只能通过精确值搜索到
可以这样理解,text用于全文搜索的, 而keyword用于关键词搜索
整数类型
类型 | 范围 |
---|---|
long | -2^ 63 - 2^63-1 |
integer | -2^31 - 2^31-1 |
short | -32,768 - 32,767 |
byte | -128 - 127 |
布尔类型
- true
- false
日期类型
es 可接受的string,或long,integer
- String : “2018-01-01” or “2018/01/01 12:00:00”
- long :milliseconds-since-the-epoch(毫秒数)
- integer :seconds-since-the-epoch(秒数)
在es内部会将日期数据转换为UTC,并存储为long型整数
通常会使用format格式化
如
"insertT": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
Reference: https://www.elastic.co/guide/en/elasticsearch/reference/6.2/date.html
二进制类型
存储的二进制数据,如图片,视频等,该类型的字段只存储不索引
其他类型
其他类型本篇文章不再介绍,具体可参看官网相关说明
Reference: https://www.elastic.co/guide/en/elasticsearch/reference/6.2/mapping-types.html