租车行网站模版,wordpress配置七牛云cdn,软件 网站开发合作协议,ps做网站72分辨率Elasticsearch中Index就相当于MySQL中的数据库表 Mapping映射就类似表的结构。 因此我们想要向Elasticsearch中存储数据,必须先创建Index和Mapping 1. Mapping映射属性 Mapping是对索引库中文档的约束#xff0c;常见的Mapping属性包括#xff1a; type#xff1a;字段数据类… Elasticsearch中Index就相当于MySQL中的数据库表 Mapping映射就类似表的结构。 因此我们想要向Elasticsearch中存储数据,必须先创建Index和Mapping 1. Mapping映射属性 Mapping是对索引库中文档的约束常见的Mapping属性包括 type字段数据类型常见的简单类型有 字符串text可分词的文本、keyword精确值例如品牌、国家、ip地址 数值long、integer、short、byte、double、float 布尔boolean 日期date 对象object index是否创建索引默认为true analyzer使用哪种分词器 properties该字段的子字段 2. 索引库操作
访问 http://192.168.218.15:5601/ (自己虚拟机IP地址加5601端口)登录Elastic控制台,点击Dev tools记得先启动kibana和es容器 2.1 创建索引库和映射
2.1.1 基本语法 请求方式PUT 请求路径/索引库名可以自定义 请求参数Mapping映射
格式
JSON格式PUT /索引库名称
{mappings: {properties: {字段名:{type: text,analyzer: ik_smart},字段名2:{type: keyword,index: false},字段名3:{properties: {子字段: {type: keyword}}},}
}
示例: PUT /duolai
{mappings: {properties: {address:{type: text,analyzer: ik_smart},phone:{type: keyword,index: false},user:{properties: {lastName: {type: keyword}}}}}
}2.1.2 测试 2.2 查询索引库
2.2.1 基本语法 请求方式GET 请求路径/索引库名 请求参数无
格式
GET /索引库名
2.2.2 测试 2.3 删除索引库 2.3.1 基本语法 请求方式DELETE 请求路径/索引库名 请求参数无
格式
DELETE /索引库名
2.3.2 测试 2.4 修改索引库
索引库和Mapping一旦创建无法修改但是可以添加新的字段。
简单来说就是不能修改已有的字段,但可以添加新的字段
2.4.1 基本语法
PUT /索引库名/_mapping
{properties: {新字段名:{type: integer}}
}
示例:
PUT /duolai/_mapping
{properties: {age:{type: integer}}
}
2.4.2 测试 查询一下索引库,看看字段是否添加 3. 总结
索引库操作有哪些 创建索引库PUT /索引库名 查询索引库GET /索引库名 删除索引库DELETE /索引库名 修改索引库添加字段PUT /索引库名/_mapping