{"id":169867,"date":"2020-01-20T08:15:28","date_gmt":"2020-01-20T00:15:28","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=169867"},"modified":"2020-01-13T13:17:27","modified_gmt":"2020-01-13T05:17:27","slug":"elasticsearch","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/elasticsearch.html","title":{"rendered":"Elasticsearch\u57fa\u7840\u6559\u7a0b"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nElasticSearch\u662f\u4e00\u4e2a\u57fa\u4e8eLucene\u7684\u641c\u7d22\u670d\u52a1\u5668\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5206\u5e03\u5f0f\u591a\u7528\u6237\u80fd\u529b\u7684\u5168\u6587\u641c\u7d22\u5f15\u64ce\uff0c\u57fa\u4e8eRESTful web\u63a5\u53e3\u3002Elasticsearch\u662f\u7528Java\u8bed\u8a00\u5f00\u53d1\u7684\uff0c\u5e76\u4f5c\u4e3aApache\u8bb8\u53ef\u6761\u6b3e\u4e0b\u7684\u5f00\u653e\u6e90\u7801\u53d1\u5e03\uff0c\u662f\u4e00\u79cd\u6d41\u884c\u7684\u4f01\u4e1a\u7ea7\u641c\u7d22\u5f15\u64ce\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
Elastic<\/strong><\/span><\/div>\n

Elastic\u5b98\u7f51\uff1ahttps:\/\/www.elastic.co\/cn\/<\/p>\n

\"\"<\/p>\n

Elastic\u6709\u4e00\u6761\u5b8c\u6574\u7684\u4ea7\u54c1\u7ebf\u53ca\u89e3\u51b3\u65b9\u6848\uff1aElasticsearch\u3001Kibana\u3001Logstash\u7b49\uff0c\u524d\u9762\u8bf4\u7684\u4e09\u4e2a\u5c31\u662f\u5927\u5bb6\u5e38\u8bf4\u7684ELK\u6280\u672f\u6808\u3002<\/p>\n

\"\"<\/p>\n

Elasticsearch<\/strong><\/span><\/div>\n

Elasticsearch\u5b98\u7f51\uff1ahttps:\/\/www.elastic.co\/cn\/products\/elasticsearch<\/p>\n

\"\"<\/p>\n

\u5982\u4e0a\u6240\u8ff0\uff0cElasticsearch\u5177\u5907\u4ee5\u4e0b\u7279\u70b9\uff1a<\/p>\n

\u5206\u5e03\u5f0f\uff0c\u65e0\u9700\u4eba\u5de5\u642d\u5efa\u96c6\u7fa4\uff08solr\u5c31\u9700\u8981\u4eba\u4e3a\u914d\u7f6e\uff0c\u4f7f\u7528Zookeeper\u4f5c\u4e3a\u6ce8\u518c\u4e2d\u5fc3\uff09<\/p>\n

Restful\u98ce\u683c\uff0c\u4e00\u5207API\u90fd\u9075\u5faaRest\u539f\u5219\uff0c\u5bb9\u6613\u4e0a\u624b<\/p>\n

\u8fd1\u5b9e\u65f6\u641c\u7d22\uff0c\u6570\u636e\u66f4\u65b0\u5728Elasticsearch\u4e2d\u51e0\u4e4e\u662f\u5b8c\u5168\u540c\u6b65\u7684\u3002<\/p>\n

\u7248\u672c<\/strong><\/span><\/div>\n

\u76ee\u524dElasticsearch\u6700\u65b0\u7684\u7248\u672c\u662f6.3.1\uff0c\u6211\u4eec\u5c31\u4f7f\u75286.3.0<\/p>\n

\"\"<\/p>\n

\u9700\u8981\u865a\u62df\u673aJDK1.8\u53ca\u4ee5\u4e0a<\/p>\n

\u5b89\u88c5\u548c\u914d\u7f6e<\/strong><\/span><\/div>\n

\u4e3a\u4e86\u6a21\u62df\u771f\u5b9e\u573a\u666f\uff0c\u6211\u4eec\u5c06\u5728linux\u4e0b\u5b89\u88c5Elasticsearch\u3002<\/p>\n

\u65b0\u5efa\u4e00\u4e2a\u7528\u6237leyou<\/strong><\/span><\/div>\n

\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0celasticsearch\u9ed8\u8ba4\u4e0d\u5141\u8bb8\u4ee5root\u8d26\u53f7\u8fd0\u884c\u3002<\/p>\n

\u521b\u5efa\u7528\u6237\uff1a<\/p>\n

\r\nuseradd leyou\r\n<\/pre>\n

\u8bbe\u7f6e\u5bc6\u7801\uff1a<\/p>\n

\r\npasswd leyou\r\n<\/pre>\n

\u5207\u6362\u7528\u6237\uff1a<\/p>\n

\r\nsu - leyou\r\n<\/pre>\n
\u4e0a\u4f20\u5b89\u88c5\u5305,\u5e76\u89e3\u538b<\/strong><\/span><\/div>\n

\u6211\u4eec\u5c06\u5b89\u88c5\u5305\u4e0a\u4f20\u5230\uff1a\/home\/leyou\u76ee\u5f55<\/p>\n

\u89e3\u538b\u7f29\uff1a<\/p>\n

\r\ntar -zxvf elasticsearch-6.2.4.tar.gz\r\n<\/pre>\n

\u5220\u9664\u538b\u7f29\u5305\uff1a<\/p>\n

\r\nrm -rf elasticsearch-6.2.4.tar.gz\r\n<\/pre>\n

\u6211\u4eec\u628a\u76ee\u5f55\u91cd\u547d\u540d\uff1a<\/p>\n

\r\nmv elasticsearch-6.2.4\/ elasticsearch\r\n<\/pre>\n

\u8fdb\u5165\uff0c\u67e5\u770b\u76ee\u5f55\u7ed3\u6784\uff1a<\/p>\n

\"\"<\/p>\n

\u4fee\u6539\u914d\u7f6e<\/strong><\/span><\/div>\n

\u6211\u4eec\u8fdb\u5165config\u76ee\u5f55\uff1acd config<\/p>\n

\u9700\u8981\u4fee\u6539\u7684\u914d\u7f6e\u6587\u4ef6\u6709\u4e24\u4e2a\uff1a<\/p>\n

\"\"<\/p>\n

jvm.options<\/strong><\/span><\/div>\n

Elasticsearch\u57fa\u4e8eLucene\u7684\uff0c\u800cLucene\u5e95\u5c42\u662fJava\u5b9e\u73b0\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u914d\u7f6ejvm\u53c2\u6570\u3002<\/p>\n

\u7f16\u8f91jvm.options\uff1a<\/p>\n

\r\nvim jvm.options\r\n\r\n\u9ed8\u8ba4\u914d\u7f6e\u5982\u4e0b\uff1a\r\n\r\n-Xms1g\r\n-Xmx1g\r\n\r\n\u5185\u5b58\u5360\u7528\u592a\u591a\u4e86\uff0c\u6211\u4eec\u8c03\u5c0f\u4e00\u4e9b\uff1a\r\n\r\n-Xms512m\r\n-Xmx512m\r\n\r\nelasticsearch.yml\r\n<\/pre>\n
\r\nvim elasticsearch.yml\r\n\r\n\u4fee\u6539\u6570\u636e\u548c\u65e5\u5fd7\u76ee\u5f55\uff1a\r\n\r\npath.data: \/home\/leyou\/elasticsearch\/data # \u6570\u636e\u76ee\u5f55\u4f4d\u7f6e\r\npath.logs: \/home\/leyou\/elasticsearch\/logs # \u65e5\u5fd7\u76ee\u5f55\u4f4d\u7f6e\r\n<\/pre>\n

\u6211\u4eec\u628adata\u548clogs\u76ee\u5f55\u4fee\u6539\u6307\u5411\u4e86elasticsearch\u7684\u5b89\u88c5\u76ee\u5f55\u3002\u4f46\u662f\u8fd9\u4e24\u4e2a\u76ee\u5f55\u5e76\u4e0d\u5b58\u5728\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u521b\u5efa\u51fa\u6765\u3002<\/p>\n

\u8fdb\u5165elasticsearch\u7684\u6839\u76ee\u5f55\uff0c\u7136\u540e\u521b\u5efa\uff1a<\/p>\n

\r\nmkdir data\r\nmkdir logs\r\n<\/pre>\n

\"\"<\/p>\n

\u4fee\u6539\u7ed1\u5b9a\u7684ip\uff1a<\/p>\n

\r\nnetwork.host: 0.0.0.0 # \u7ed1\u5b9a\u52300.0.0.0\uff0c\u5141\u8bb8\u4efb\u4f55ip\u6765\u8bbf\u95ee\r\n<\/pre>\n

\u9ed8\u8ba4\u53ea\u5141\u8bb8\u672c\u673a\u8bbf\u95ee\uff0c\u4fee\u6539\u4e3a0.0.0.0\u540e\u5219\u53ef\u4ee5\u8fdc\u7a0b\u8bbf\u95ee<\/p>\n

\u76ee\u524d\u6211\u4eec\u662f\u505a\u7684\u5355\u673a\u5b89\u88c5\uff0c\u5982\u679c\u8981\u505a\u96c6\u7fa4\uff0c\u53ea\u9700\u8981\u5728\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u5176\u5b83\u8282\u70b9\u4fe1\u606f\u5373\u53ef\u3002<\/p>\n

elasticsearch.yml\u7684\u5176\u5b83\u53ef\u914d\u7f6e\u4fe1\u606f\uff1a<\/p>\n

\r\n\u5c5e\u6027\u540d\t\u8bf4\u660e\r\ncluster.name \t\u914d\u7f6eelasticsearch\u7684\u96c6\u7fa4\u540d\u79f0\uff0c\u9ed8\u8ba4\u662felasticsearch\u3002\u5efa\u8bae\u4fee\u6539\u6210\u4e00\u4e2a\u6709\u610f\u4e49\u7684\u540d\u79f0\u3002\r\nnode.name \t\u8282\u70b9\u540d\uff0ces\u4f1a\u9ed8\u8ba4\u968f\u673a\u6307\u5b9a\u4e00\u4e2a\u540d\u5b57\uff0c\u5efa\u8bae\u6307\u5b9a\u4e00\u4e2a\u6709\u610f\u4e49\u7684\u540d\u79f0\uff0c\u65b9\u4fbf\u7ba1\u7406\r\npath.conf \t\u8bbe\u7f6e\u914d\u7f6e\u6587\u4ef6\u7684\u5b58\u50a8\u8def\u5f84\uff0ctar\u6216zip\u5305\u5b89\u88c5\u9ed8\u8ba4\u5728es\u6839\u76ee\u5f55\u4e0b\u7684config\u6587\u4ef6\u5939\uff0crpm\u5b89\u88c5\u9ed8\u8ba4\u5728\/etc\/ elasticsearch\r\npath.data \t\u8bbe\u7f6e\u7d22\u5f15\u6570\u636e\u7684\u5b58\u50a8\u8def\u5f84\uff0c\u9ed8\u8ba4\u662fes\u6839\u76ee\u5f55\u4e0b\u7684data\u6587\u4ef6\u5939\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2a\u5b58\u50a8\u8def\u5f84\uff0c\u7528\u9017\u53f7\u9694\u5f00\r\npath.logs \t\u8bbe\u7f6e\u65e5\u5fd7\u6587\u4ef6\u7684\u5b58\u50a8\u8def\u5f84\uff0c\u9ed8\u8ba4\u662fes\u6839\u76ee\u5f55\u4e0b\u7684logs\u6587\u4ef6\u5939\r\npath.plugins \t\u8bbe\u7f6e\u63d2\u4ef6\u7684\u5b58\u653e\u8def\u5f84\uff0c\u9ed8\u8ba4\u662fes\u6839\u76ee\u5f55\u4e0b\u7684plugins\u6587\u4ef6\u5939\r\nbootstrap.memory_lock \t\u8bbe\u7f6e\u4e3atrue\u53ef\u4ee5\u9501\u4f4fES\u4f7f\u7528\u7684\u5185\u5b58\uff0c\u907f\u514d\u5185\u5b58\u8fdb\u884cswap\r\nnetwork.host \t\u8bbe\u7f6ebind_host\u548cpublish_host\uff0c\u8bbe\u7f6e\u4e3a0.0.0.0\u5141\u8bb8\u5916\u7f51\u8bbf\u95ee\r\nhttp.port \t\u8bbe\u7f6e\u5bf9\u5916\u670d\u52a1\u7684http\u7aef\u53e3\uff0c\u9ed8\u8ba4\u4e3a9200\u3002\r\ntransport.tcp.port \t\u96c6\u7fa4\u7ed3\u70b9\u4e4b\u95f4\u901a\u4fe1\u7aef\u53e3\r\ndiscovery.zen.ping.timeout \t\u8bbe\u7f6eES\u81ea\u52a8\u53d1\u73b0\u8282\u70b9\u8fde\u63a5\u8d85\u65f6\u7684\u65f6\u95f4\uff0c\u9ed8\u8ba4\u4e3a3\u79d2\uff0c\u5982\u679c\u7f51\u7edc\u5ef6\u8fdf\u9ad8\u53ef\u8bbe\u7f6e\u5927\u4e9b\r\ndiscovery.zen.minimum_master_nodes \t\u4e3b\u7ed3\u70b9\u6570\u91cf\u7684\u6700\u5c11\u503c ,\u6b64\u503c\u7684\u516c\u5f0f\u4e3a\uff1a(master_eligible_nodes \/ 2) + 1 \uff0c\u6bd4\u5982\uff1a\u67093\u4e2a\u7b26\u5408\u8981\u6c42\u7684\u4e3b\u7ed3\u70b9\uff0c\u90a3\u4e48\u8fd9\u91cc\u8981\u8bbe\u7f6e\u4e3a2\r\n<\/pre>\n

\u4fee\u6539\u6587\u4ef6\u6743\u9650\uff1a<\/p>\n

leyou \u8981own(\u62e5\u6709) elasticsearch \u8fd9\u4e2a\u6587\u4ef6\u5939\u6743\u9650 -R \u662f\u9012\u5f52\u7684\u8d4b\u4e88\u6743\u9650<\/p>\n

\r\nchown leyou:leyou elasticsearch\/ -R\r\n<\/pre>\n
\u8fd0\u884c<\/strong><\/span><\/div>\n

\u8fdb\u5165elasticsearch\/bin\u76ee\u5f55\uff0c\u53ef\u4ee5\u770b\u5230\u4e0b\u9762\u7684\u6267\u884c\u6587\u4ef6\uff1a<\/p>\n

\"\"<\/p>\n

\u7136\u540e\u8f93\u5165\u547d\u4ee4\uff1a<\/p>\n

\r\n.\/elasticsearch\r\n<\/pre>\n

\u53d1\u73b0\u62a5\u9519\u4e86\uff0c\u542f\u52a8\u5931\u8d25\uff1a<\/p>\n

\u9519\u8bef1\uff1a\u5185\u6838\u8fc7\u4f4e<\/strong><\/span><\/div>\n

\"\"<\/p>\n

\u6211\u4eec\u4f7f\u7528\u7684\u662fCentOS6\uff0c\u5176linux\u5185\u6838\u7248\u672c\u4e3a2.6\u3002\u800cElasticsearch\u7684\u63d2\u4ef6\u8981\u6c42\u81f3\u5c113.5\u4ee5\u4e0a\u7248\u672c\u3002\u4e0d\u8fc7\u6ca1\u5173\u7cfb\uff0c\u6211\u4eec\u7981\u7528\u8fd9\u4e2a\u63d2\u4ef6\u5373\u53ef\u3002<\/p>\n

\u4fee\u6539elasticsearch.yml\u6587\u4ef6\uff0c\u5728\u6700\u4e0b\u9762\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e\uff1a<\/p>\n

\r\nbootstrap.system_call_filter: false\r\n<\/pre>\n

\u7136\u540e\u91cd\u542f<\/p>\n

\u9519\u8bef2\uff1a\u6587\u4ef6\u6743\u9650\u4e0d\u8db3<\/strong><\/span><\/div>\n

\u518d\u6b21\u542f\u52a8\uff0c\u53c8\u51fa\u9519\u4e86\uff1a<\/p>\n

\"\"<\/p>\n

[1]: max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]<\/p>\n

\u6211\u4eec\u7528\u7684\u662fleyou\u7528\u6237\uff0c\u800c\u4e0d\u662froot\uff0c\u6240\u4ee5\u6587\u4ef6\u6743\u9650\u4e0d\u8db3\u3002<\/p>\n

\u9996\u5148\u7528root\u7528\u6237\u767b\u5f55\u3002<\/p>\n

\u7136\u540e\u4fee\u6539\u914d\u7f6e\u6587\u4ef6:<\/p>\n

\r\nvim \/etc\/security\/limits.conf\r\n\r\n\u6dfb\u52a0\u4e0b\u9762\u7684\u5185\u5bb9\uff1a\r\n\r\n* soft nofile 65536\r\n\r\n* hard nofile 131072\r\n\r\n* soft nproc 4096\r\n\r\n* hard nproc 4096\r\n<\/pre>\n
\u9519\u8bef3\uff1a\u7ebf\u7a0b\u6570\u4e0d\u591f<\/strong><\/span><\/div>\n

\u521a\u624d\u62a5\u9519\u4e2d\uff0c\u8fd8\u6709\u4e00\u884c\uff1a<\/p>\n

[1]: max number of threads [1024] for user [leyou] is too low, increase to at least [4096]<\/p>\n

\u8fd9\u662f\u7ebf\u7a0b\u6570\u4e0d\u591f\u3002<\/p>\n

\u7ee7\u7eed\u4fee\u6539\u914d\u7f6e\uff1a<\/p>\n

\r\nvim \/etc\/security\/limits.d\/90-nproc.conf \r\n\r\n\u4fee\u6539\u4e0b\u9762\u7684\u5185\u5bb9\uff1a\r\n\r\n* soft nproc 1024\r\n\r\n\u6539\u4e3a\uff1a\r\n\r\n* soft nproc 4096\r\n<\/pre>\n
\u9519\u8bef4\uff1a\u8fdb\u7a0b\u865a\u62df\u5185\u5b58<\/strong><\/span><\/div>\n

[3]: max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]<\/p>\n

vm.max_map_count\uff1a\u9650\u5236\u4e00\u4e2a\u8fdb\u7a0b\u53ef\u4ee5\u62e5\u6709\u7684VMA(\u865a\u62df\u5185\u5b58\u533a\u57df)\u7684\u6570\u91cf\uff0c\u7ee7\u7eed\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\uff0c \uff1a<\/p>\n

\r\nvim \/etc\/sysctl.conf \r\n\r\n\u6dfb\u52a0\u4e0b\u9762\u5185\u5bb9\uff1a\r\n\r\nvm.max_map_count=655360\r\n\r\n\u7136\u540e\u6267\u884c\u547d\u4ee4\uff1a\r\n\r\nsysctl -p\r\n<\/pre>\n
\u91cd\u542f\u7ec8\u7aef\u7a97\u53e3<\/strong><\/span><\/div>\n

\u6240\u6709\u9519\u8bef\u4fee\u6539\u5b8c\u6bd5\uff0c\u4e00\u5b9a\u8981\u91cd\u542f\u4f60\u7684 Xshell\u7ec8\u7aef\uff0c\u5426\u5219\u914d\u7f6e\u65e0\u6548\u3002<\/p>\n

\u542f\u52a8<\/strong><\/span><\/div>\n

\u518d\u6b21\u542f\u52a8\uff0c\u7ec8\u4e8e\u6210\u529f\u4e86\uff01<\/p>\n

\"\"<\/p>\n

\u53ef\u4ee5\u770b\u5230\u7ed1\u5b9a\u4e86\u4e24\u4e2a\u7aef\u53e3:<\/p>\n

9300\uff1a\u96c6\u7fa4\u8282\u70b9\u95f4\u901a\u8baf\u63a5\u53e3<\/p>\n

9200\uff1a\u5ba2\u6237\u7aef\u8bbf\u95ee\u63a5\u53e3<\/p>\n

\u6211\u4eec\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee\uff1ahttp:\/\/192.168.56.101:9200<\/p>\n

\"\"<\/p>\n

\u5b89\u88c5kibana<\/strong><\/span><\/div>\n

1.4.1.\u4ec0\u4e48\u662fKibana\uff1f<\/p>\n

\"\"<\/p>\n

Kibana\u662f\u4e00\u4e2a\u57fa\u4e8eNode.js\u7684Elasticsearch\u7d22\u5f15\u5e93\u6570\u636e\u7edf\u8ba1\u5de5\u5177\uff0c\u53ef\u4ee5\u5229\u7528Elasticsearch\u7684\u805a\u5408\u529f\u80fd\uff0c\u751f\u6210\u5404\u79cd\u56fe\u8868\uff0c\u5982\u67f1\u5f62\u56fe\uff0c\u7ebf\u72b6\u56fe\uff0c\u997c\u56fe\u7b49\u3002<\/p>\n

\u800c\u4e14\u8fd8\u63d0\u4f9b\u4e86\u64cd\u4f5cElasticsearch\u7d22\u5f15\u6570\u636e\u7684\u63a7\u5236\u53f0\uff0c\u5e76\u4e14\u63d0\u4f9b\u4e86\u4e00\u5b9a\u7684API\u63d0\u793a\uff0c\u975e\u5e38\u6709\u5229\u4e8e\u6211\u4eec\u5b66\u4e60Elasticsearch\u7684\u8bed\u6cd5\u3002<\/p>\n

\u5b89\u88c5<\/strong><\/span><\/div>\n

\u56e0\u4e3aKibana\u4f9d\u8d56\u4e8enode\uff0c\u6211\u4eec\u7684\u865a\u62df\u673a\u6ca1\u6709\u5b89\u88c5node\uff0c\u800cwindow\u4e2d\u5b89\u88c5\u8fc7\u3002\u6240\u4ee5\u6211\u4eec\u9009\u62e9\u5728window\u4e0b\u4f7f\u7528kibana\u3002<\/p>\n

\u6700\u65b0\u7248\u672c\u4e0eelasticsearch\u4fdd\u6301\u4e00\u81f4\uff0c\u4e5f\u662f6.3.0<\/p>\n

\"\"<\/p>\n

\u89e3\u538b\u5230\u7279\u5b9a\u76ee\u5f55\u5373\u53ef<\/p>\n

\u914d\u7f6e\u8fd0\u884c<\/strong><\/span><\/div>\n

\u8fdb\u5165\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684config\u76ee\u5f55\uff0c\u4fee\u6539kibana.yml\u6587\u4ef6\uff1a<\/p>\n

\u4fee\u6539elasticsearch\u670d\u52a1\u5668\u7684\u5730\u5740\uff1a<\/p>\n

\r\nelasticsearch.url: \"http:\/\/192.168.56.101:9200\"\r\n<\/pre>\n
\u8fd0\u884c<\/strong><\/span><\/div>\n

\u8fdb\u5165\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684bin\u76ee\u5f55\uff1a<\/p>\n

\"\"<\/p>\n

\u53cc\u51fb\u8fd0\u884c\uff1a<\/p>\n

\"\"<\/p>\n

\u53d1\u73b0kibana\u7684\u76d1\u542c\u7aef\u53e3\u662f5601<\/p>\n

\u6211\u4eec\u8bbf\u95ee\uff1ahttp:\/\/127.0.0.1:5601<\/p>\n

\"\"<\/p>\n

\u63a7\u5236\u53f0<\/strong><\/span><\/div>\n

\u9009\u62e9\u5de6\u4fa7\u7684DevTools\u83dc\u5355\uff0c\u5373\u53ef\u8fdb\u5165\u63a7\u5236\u53f0\u9875\u9762\uff1a<\/p>\n

\"\"<\/p>\n

\u5728\u9875\u9762\u53f3\u4fa7\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u8f93\u5165\u8bf7\u6c42\uff0c\u8bbf\u95eeElasticsearch\u4e86\u3002<\/p>\n

\"\"<\/p>\n

\u5b89\u88c5ik\u5206\u8bcd\u5668<\/strong><\/span><\/div>\n

Lucene\u7684IK\u5206\u8bcd\u5668\u65e9\u57282012\u5e74\u5df2\u7ecf\u6ca1\u6709\u7ef4\u62a4\u4e86\uff0c\u73b0\u5728\u6211\u4eec\u8981\u4f7f\u7528\u7684\u662f\u5728\u5176\u57fa\u7840\u4e0a\u7ef4\u62a4\u5347\u7ea7\u7684\u7248\u672c\uff0c\u5e76\u4e14\u5f00\u53d1\u4e3aElasticSearch\u7684\u96c6\u6210\u63d2\u4ef6\u4e86\uff0c\u4e0eElasticsearch\u4e00\u8d77\u7ef4\u62a4\u5347\u7ea7\uff0c\u7248\u672c\u4e5f\u4fdd\u6301\u4e00\u81f4\uff0c\u6700\u65b0\u7248\u672c\uff1a6.3.0<\/p>\n

\u5b89\u88c5<\/strong><\/span><\/div>\n

\u4e0a\u4f20\u8d44\u6599\u4e2d\u7684zip\u5305\uff0c\u89e3\u538b\u5230Elasticsearch\u76ee\u5f55\u7684plugins\u76ee\u5f55\u4e2d\uff1a<\/p>\n

\"\"<\/p>\n

\u4f7f\u7528unzip\u547d\u4ee4\u89e3\u538b\uff1a<\/p>\n

\r\nunzip elasticsearch-analysis-ik-6.3.0.zip -d ik-analyzer\r\n<\/pre>\n

\u7136\u540e\u91cd\u542felasticsearch\uff1a<\/p>\n

\"\"<\/p>\n

\u6d4b\u8bd5<\/strong><\/span><\/div>\n

\u5927\u5bb6\u5148\u4e0d\u7ba1\u8bed\u6cd5\uff0c\u6211\u4eec\u5148\u6d4b\u8bd5\u4e00\u6ce2\u3002<\/p>\n

\u5728kibana\u63a7\u5236\u53f0\u8f93\u5165\u4e0b\u9762\u7684\u8bf7\u6c42\uff1a<\/p>\n

\r\nPOST _analyze\r\n{\r\n  \"analyzer\": \"ik_max_word\",\r\n  \"text\":     \"\u6211\u662f\u4e2d\u56fd\u4eba\"\r\n}\r\n<\/pre>\n

\u8fd0\u884c\u5f97\u5230\u7ed3\u679c\uff1a<\/p>\n

\r\n{\r\n  \"tokens\": [\r\n    {\r\n      \"token\": \"\u6211\",\r\n      \"start_offset\": 0,\r\n      \"end_offset\": 1,\r\n      \"type\": \"CN_CHAR\",\r\n      \"position\": 0\r\n    },\r\n    {\r\n      \"token\": \"\u662f\",\r\n      \"start_offset\": 1,\r\n      \"end_offset\": 2,\r\n      \"type\": \"CN_CHAR\",\r\n      \"position\": 1\r\n    },\r\n    {\r\n      \"token\": \"\u4e2d\u56fd\u4eba\",\r\n      \"start_offset\": 2,\r\n      \"end_offset\": 5,\r\n      \"type\": \"CN_WORD\",\r\n      \"position\": 2\r\n    },\r\n    {\r\n      \"token\": \"\u4e2d\u56fd\",\r\n      \"start_offset\": 2,\r\n      \"end_offset\": 4,\r\n      \"type\": \"CN_WORD\",\r\n      \"position\": 3\r\n    },\r\n    {\r\n      \"token\": \"\u56fd\u4eba\",\r\n      \"start_offset\": 3,\r\n      \"end_offset\": 5,\r\n      \"type\": \"CN_WORD\",\r\n      \"position\": 4\r\n    }\r\n  ]\r\n}\r\n<\/pre>\n
\u8f6f\u4ef6\u5305\u4e0b\u8f7d<\/strong><\/span><\/div>\n

\u94fe\u63a5: https:\/\/pan.baidu.com\/s\/1KeIQtkCRDlnba6L73lkXEg \u63d0\u53d6\u7801:mm99<\/p>\n","protected":false},"excerpt":{"rendered":"

Elastic\u5b98\u7f51\uff1ahttps:\/\/www.elastic.co\/cn\/ Elastic\u6709\u4e00\u6761\u5b8c\u6574\u7684\u4ea7\u54c1\u7ebf\u53ca\u89e3 […]<\/p>\n","protected":false},"author":1479,"featured_media":81571,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-169867","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/169867","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1479"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=169867"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/169867\/revisions"}],"predecessor-version":[{"id":169892,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/169867\/revisions\/169892"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/81571"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=169867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=169867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=169867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}