目录
一、Mapping属性
mapping是对索引库中文档的约束,常见的mapping属性包括:
type:字段数据类型,常见的简单类型有:
- 字符串: text(可分词的文本)、keyword(精确值,例如:品牌、国家、ip地址)
- 数值: long.integer、short、byte、double、float
- 布尔: boolean
- 日期:date
- 对象:object
index:是否创建索引,默认为true
analyzer:使用哪种分词器
properties:该字段的子字段
二、创建索引库
1、在DevTools中编写代码
PUT /hm
{
"mappings": {
"properties": {
"info": {
"type": "text",
"analyzer": "ik_smart"
},
"email": {
"type": "keyword",
"index": false
},
"name": {
"type": "object",
"properties": {
"firstName": {
"type": "keyword"
},
"lastName": {
"type": "keyword"
}
}
}
}
}
}
2、运行并查看

三、查询索引库
1、查询索引库语法:
GET /索引库名

四、删除索引库
1、删除索引库语法
DELETE /索引库名

五、修改索引库
索引库不允许修改!!!
但是可以添加新的字段
PUT /索引库名/_mapping
{
"properties": {
"新字段名":{
"type": "integer"
}
}
}