1.index
:控制当前字段是否索引,默认为true,即记录索引,false不记录,即不可搜索
发现无法搜索,因为我设置了name不可搜索
2.数据类型
核心数据类型:
- 字符串型:text、keyword
- 数值型:long、integer、short、byte、double、float、half_float、scaled_float
- 日志类型:date
- 布尔类型:boolean
- 二进制类型:binary
- 范围类型:integer_range、float_range、long_range、double_range、date_range
- 复杂数据类型:
- 属组类型:array
- 对象类型:object
- 嵌套类型:nested object
- 地理位置数据类型:
- geo_point
- geo_shape
专用类型:
- 记录IP地址 ip
- 实现自动补全 completion
- 记录分词数 token_count
- 记录字符串hash值 murmur3
- percolator
- join
multi-fields多字段特性
允许对同一个字段采用不同的配置,比如分词,常见的例子如对人名实现拼音搜索,只需要在人名中新增一个子字段为pinyin即可。
PUT myindex1
{
"mappings": {
"doc": {
"properties": {
"username": {
"type":"text",
"fields": {
"pinyin": {
"type": "text",
"analyzer": "pinyin"
}
}
}
}
}
}
}