1、创建索引库
- 使用postman创建索引库,我用的es是5.6.8版本的,不同的版本创建略有区别(一般是7.x以上)
- 使用postman发送json数据
{
"mappings":{
"articles":{
"properties":{
"id":{
"type":"long",
"store":true
},
"title":{
"type":"text",
"store":true,
"index":"analyzed",
"analyzer":"standard"
},
"content":{
"type":"text",
"store":true,
"index":"analyzed",
"analyzer":"standard"
}
}
}
}
}
- 这里的blog1就是我们的索引库的名字,这里相当于数据库。put请求是创建的意思。mapping是一个关键字,指的是映射,articles指的是type,相当于数据库中的表,properties指的是一个field相当于数据库中的字段。
- 得到返回结果
- 创建成功
- 也直接可以在es图形化界面中创建索引,点击新建索引
- 这里面创建的索引,mapping是空的,我们可以再次用postman去设置mapping
2、删除索引库
- 更换请求方式为delete