当前位置: 首页 > 科技观察

谈谈Elastic-Search的部署与应用

时间:2023-03-18 15:11:16 科技观察

Elasticsearch简介Elasticsearch是一个分布式、可扩展的实时搜索分析引擎,基于全文搜索引擎ApacheLucene(TM)的搜索引擎Elastic官网https://www.elastic.co/cn/主要功能:distribution类型搜索数据分析分组聚合es下载地址https://www.elastic.co/cn/downloads/linux安装es把下载的安装包传到linux服务器上,我的版本是elasticsearch-7.2.0-linux-x86_64.tar.gz创建usr/local/soft/es目录,将es解压到该目录下并修改es的yum文件node.name:node-1//这个很重要http.host:0.0.0.0http.port:9200修改es的jvm.options-Xms256M-Xmx256M新建一个用户启动esuseraddesusergrantpermissionchown-Resuser:esuser/usr/local/software/elasticsearch-7.2.0切换到esuser用户suesuserstartessh通过es用户后台elasticsearch-d验证是否启动成功curl-XGET"http://localhost:9200"将ik添加到es中下载ik的版本必须对应es版本把ik放在es的插件目录下解压es重启后会加载newindexinikespostcurl-XPUT"localhost:9200/post"修改tokenizer为ikCloseindexPOSTpost/_close配置ikPUTpost/_settings{"number_of_replicas":0,"index":{"analysis.analyzer.default.type":"ik_max_word","analysis.search_analyzer.default.type":"ik_smart"}}打开post索引POSTpost/_opencreateesmapping,根据需要创建curl--location--requestPUT'787k.fun:9200/post/_mapping'\--header'Content-Type:application/json'\--data-raw'{"properties":{"id":{"type":"integer"},"title":{"type":“文本”},“内容”:{“类型”:“文本”},“blogImg”:{“类型”:“关键字”},“html_content”:{“类型”:“关键字”},“authorId":{"type":"integer"},"authorName":{"type":"keyword"},"tag":{"type":"integer"},"type":{"type":"整数"},"status":{"type":"integer"},"commentCount":{"type":"integer"},"score":{"type":"double"},"created":{"type":"date"},"updated":{"type":"date"}}}'springboot集合成espom文件加入依赖org.elasticsearch.clientelasticsearch-rest-high-level-client7??.2.0org.elasticsearchelasticsearch7??.2.0yum文件添加文件elasticsearch.host=localhostelasticsearch.port=9200