概念对比
一. mapping索引属性
二. 索引库的操作
1. 创建索引库
实例:
#创建索引库
PUT /heima
{
"mappings": {
"properties": {
"info": {
"type": "text",
"analyzer": "ik_smart"
},
"email": {
"type": "keyword",
"index": false
},
"name": {
"type": "object",
"properties": {
"firstname": {
"type": "keyword"
},
"lastname": {
"type": "keyword"
}
}
}
}
}
}
2. 索引库的其他操作(查看,删除,修改(只能添加新的字段)):
ps:索引库创建好后
理论上是可以进行修改的
但是实际开发中,是禁止去修改原有的字段的(但可以添加新的字段),因为修改会对性能的影响是很大的,可能会导致整个库都不可用
(实例)代码:
# 查询
GET /heima
# 修改索引库,添加新字段
PUT /heima/_mapping
{
"properties": {
"age": {
"type": "integer"
}
}
}
# 删除
DELETE /heima