作者:牵绊2502897683 | 来源:互联网 | 2024-11-20 08:52
本章节详细介绍了如何在开发环境中搭建Elasticsearch(ES)环境,包括安装、启动服务端以及创建索引和映射的具体步骤。对于旧版ES环境的清理方法也进行了说明。
3.3 构建Elasticsearch环境
3.3.1 Elasticsearch安装
在开发环境中配置Elasticsearch单机模式,并启动服务端。如果需要更新或重置环境,建议先删除旧的Elasticsearch数据文件夹(例如:elasticsearch-6.2.1\data\nodes),以确保环境的干净。
安装并启动elasticsearch-head插件,以便通过Web界面管理ES集群。
3.3.2 创建索引库
接下来,我们将创建名为xc_course的索引库,设置1个分片,无副本。
3.3.3 配置映射
通过HTTP POST请求向xc_course索引添加文档映射,具体配置如下:
{ "properties": { "description": { "analyzer": "ik_max_word", "search_analyzer": "ik_smart", "type": "text" }, "grade": { "type": "keyword" }, "id": { "type": "keyword" }, "mt": { "type": "keyword" }, "name": { "analyzer": "ik_max_word", "search_analyzer": "ik_smart", "type": "text" }, "users": { "index": false, "type": "text" }, "charge": { "type": "keyword" }, "valid": { "type": "keyword" }, "pic": { "index": false, "type": "keyword" }, "qq": { "index": false, "type": "keyword" }, "price": { "type": "float" }, "price_old": { "type": "float" }, "st": { "type": "keyword" }, "status": { "type": "keyword" }, "studymodel": { "type": "keyword" }, "teachmode": { "type": "keyword" }, "teachplan": { "analyzer": "ik_max_word", "search_analyzer": "ik_smart", "type": "text" }, "expires": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss" }, "pub_time": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss" }, "start_time": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss" }, "end_time": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss" } } }