Elasticsearch索引库基础操作
mapping映射属性
mapping 是对索引库中文档的约束,常见的mapping包括:
1.type:字段数据类型 字符串 text(可分词文本) 、keyword(精确值,品牌,国家,ip地址) 数值 long... 布尔boolean 日期 date 对象object
2.index 是否创建索引 默认为true
3.analyzer 使用哪种分词器
4.properties:该字段的子字段
创建索引库
ES通过Restful库请求操作索引库、文档,请求内容用DSL语句表示。
PUT /hahaha { "mappings": { "properties": { "info":{ "type": "text", "analyzer": "ik_smart" }, "email":{ "type": "keyword", "index": false }, "name":{ "type": "object", "properties": { "firstName":{ "type":"keyword" }, "lastName":{ "type":"keyword" } } } } } }
查看索引库 GET /NAME
删除索引库 DELETE / NAME
修改索引库 允许添加新字段 不允许修改字段 PUT /索引库名字/_mapping{新字段}

浙公网安备 33010602011771号