1 创建索引及TYPE
1.1 创建索引
可在head中直接界面操作添加
使用命令语句创建
| { "settings": { "index": { "number_of_shards": 5, "number_of_replicas": 1 } } }
|
1.2 创建type
"analyzer": "ik" 中文分词
| { "news": { "properties": { "content": { "analyzer": "ik", "type": "string" }, "author": { "index": "not_analyzed", "type": "string" }, "title": { "type": "string" }, "category": { "index": "not_analyzed", "type": "string" }, "publish_date": { "format": "yyyy/mm/dd", "type": "date" } } } } |
1.3 同时创建index及type
| { "settings": { "index": { "number_of_replicas": "1", "number_of_shards": "5" } }, "mappings": { "news": { "properties": { "content": { "analyzer": "ik", "type": "string" }, "author": { "index": "not_analyzed", "type": "string" }, "title": { "analyzer": "ik", "boost": 5, "type": "string" }, "category": { "index": "not_analyzed", "type": "string" }, "publish_date": { "format": "yyyy/mm/dd", "type": "date" } } } } } |
本文介绍如何在Elasticsearch中创建索引和文档类型,包括设置分片数量、副本数量以及定义字段的分析器和数据类型等。




1273

被折叠的 条评论
为什么被折叠?



