{"id":198669,"date":"2020-08-27T08:12:24","date_gmt":"2020-08-27T00:12:24","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=198669"},"modified":"2020-08-19T17:12:50","modified_gmt":"2020-08-19T09:12:50","slug":"elasticsearch-lucene","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/elasticsearch-lucene.html","title":{"rendered":"Elasticsearch Lucene\u662f\u600e\u6837\u6570\u636e\u5199\u5165\u7684"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | Elasticsearch\u662f\u4e0e\u540d\u4e3aLogstash\u7684\u6570\u636e\u6536\u96c6\u548c\u65e5\u5fd7\u89e3\u6790\u5f15\u64ce\u4ee5\u53ca\u540d\u4e3aKibana\u7684\u5206\u6790\u548c\u53ef\u89c6\u5316\u5e73\u53f0\u4e00\u8d77\u5f00\u53d1\u7684\u3002\u8fd9\u4e09\u4e2a\u4ea7\u54c1\u88ab\u8bbe\u8ba1\u6210\u4e00\u4e2a\u96c6\u6210\u89e3\u51b3\u65b9\u6848\uff0c\u79f0\u4e3a\u201cElastic Stack\u201d\uff08\u4ee5\u524d\u79f0\u4e3a\u201cELK stack\u201d\uff09\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <\/p>\n Elasticsearch & Lucene \u662f\u4ec0\u4e48<\/strong><\/div>\n Elasticsearch \u662f\u4e00\u4e2a\u57fa\u4e8e Apache Lucene(TM) \u7684\u5f00\u6e90\u641c\u7d22\u5f15\u64ce\u3002<\/p>\n \u90a3 Lucene \u662f\u4ec0\u4e48\uff1f<\/strong><\/div>\n \u65e0\u8bba\u5728\u5f00\u6e90\u8fd8\u662f\u4e13\u6709\u9886\u57df\uff0cLucene \u53ef\u4ee5\u88ab\u8ba4\u4e3a\u662f\u8fc4\u4eca\u4e3a\u6b62\u6700\u5148\u8fdb\u3001\u6027\u80fd\u6700\u597d\u7684\u3001\u529f\u80fd\u6700\u5168\u7684\u641c\u7d22\u5f15\u64ce\u5e93\uff0c\u5e76\u901a\u8fc7\u7b80\u5355\u7684 RESTful API \u6765\u9690\u85cf Lucene \u7684\u590d\u6742\u6027\uff0c\u4ece\u800c\u8ba9\u5168\u6587\u641c\u7d22\u53d8\u5f97\u7b80\u5355\u3002<\/p>\n Elasticsearch \u4e0d\u4ec5\u4ec5\u662f Lucene \u548c\u5168\u6587\u641c\u7d22\uff0c\u6211\u4eec\u8fd8\u80fd\u8fd9\u6837\u53bb\u63cf\u8ff0\u5b83\uff1a<\/p>\n \u2013 \u5206\u5e03\u5f0f\u7684\u5b9e\u65f6\u6587\u4ef6\u5b58\u50a8\uff0c\u6bcf\u4e2a\u5b57\u6bb5\u90fd\u88ab\u7d22\u5f15\u5e76\u53ef\u88ab\u641c\u7d22<\/p>\n \u2013 \u5206\u5e03\u5f0f\u7684\u5b9e\u65f6\u5206\u6790\u641c\u7d22\u5f15\u64ce<\/p>\n \u2013 \u53ef\u4ee5\u6269\u5c55\u5230\u4e0a\u767e\u53f0\u670d\u52a1\u5668\uff0c\u5904\u7406 PB \u7ea7\u7ed3\u6784\u5316\u6216\u975e\u7ed3\u6784\u5316\u6570\u636e<\/p>\n Elasticsearch & Lucene \u7684\u5173\u7cfb<\/strong><\/div>\n \u5c31\u50cf\u5f88\u591a\u4e1a\u52a1\u7cfb\u7edf\u662f\u57fa\u4e8e Spring \u5b9e\u73b0\u4e00\u6837\uff0cElasticsearch \u548c Lucene \u7684\u5173\u7cfb\u5f88\u7b80\u5355\uff1aElasticsearch \u662f\u57fa\u4e8e Lucene \u5b9e\u73b0\u7684\u3002ES \u57fa\u4e8e\u5e95\u5c42\u8fd9\u4e9b\u5305\uff0c\u7136\u540e\u8fdb\u884c\u4e86\u6269\u5c55\uff0c\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u66f4\u4e30\u5bcc\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u5e76\u4e14\u901a\u8fc7 RESTful API \u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u4e0e\u5e95\u5c42\u4ea4\u4e92\u3002\u7c7b\u4f3c ES \u8fd8\u6709 Solr \u4e5f\u662f\u57fa\u4e8e Lucene \u5b9e\u73b0\u7684\u3002<\/p>\n \u5728\u5e94\u7528\u5f00\u53d1\u4e2d\uff0c\u7528 Elasticsearch \u4f1a\u5f88\u7b80\u5355\u3002\u4f46\u662f\u5982\u679c\u4f60\u76f4\u63a5\u7528 Lucene\uff0c\u4f1a\u6709\u5927\u91cf\u7684\u96c6\u6210\u5de5\u4f5c\u3002<\/p>\n \u56e0\u6b64\uff0c\u5165\u95e8 ES \u7684\u540c\u5b66\uff0c\u7a0d\u5fae\u4e86\u89e3\u4e0b Lucene \u5373\u53ef\u3002\u5982\u679c\u5f80\u9ad8\u7ea7\u8d70\uff0c\u8fd8\u662f\u9700\u8981\u5b66\u4e60 Lucene \u5e95\u5c42\u7684\u539f\u7406\u3002\u56e0\u4e3a\u5012\u6392\u7d22\u5f15\u3001\u6253\u5206\u673a\u5236\u3001\u5168\u6587\u68c0\u7d22\u539f\u7406\u3001\u5206\u8bcd\u539f\u7406\u7b49\u7b49\uff0c\u8fd9\u4e9b\u90fd\u662f\u4e0d\u4f1a\u8fc7\u65f6\u7684\u6280\u672f\u3002<\/p>\n \u65b0\u6587\u6863\u5199\u5165\u6d41\u7a0b<\/strong><\/div>\n \u6570\u636e\u6a21\u578b<\/strong><\/span><\/div>\n \u4e00\u4e2a ES Index \uff08\u7d22\u5f15\uff0c\u6bd4\u5982\u5546\u54c1\u641c\u7d22\u7d22\u5f15\u3001\u8ba2\u5355\u641c\u7d22\u7d22\u5f15\uff09\u96c6\u7fa4\u4e0b\uff0c\u6709\u591a\u4e2a Node \uff08\u8282\u70b9\uff09\u7ec4\u6210\u3002\u6bcf\u4e2a\u8282\u70b9\u5c31\u662f ES \u7684\u5b9e\u4f8b\u3002<\/p>\n \u6bcf\u4e2a\u8282\u70b9\u4e0a\u4f1a\u6709\u591a\u4e2a shard \uff08\u5206\u7247\uff09\uff0c P1 P2 \u662f\u4e3b\u5206\u7247 R1 R2 \u662f\u526f\u672c\u5206\u7247<\/p>\n \u6bcf\u4e2a\u5206\u7247\u4e0a\u5bf9\u5e94\u7740\u5c31\u662f\u4e00\u4e2a Lucene Index\uff08\u5e95\u5c42\u7d22\u5f15\u6587\u4ef6\uff09<\/p>\n Lucene Index \u662f\u4e00\u4e2a\u7edf\u79f0\u3002\u7531\u591a\u4e2a Segment \uff08\u6bb5\u6587\u4ef6\uff0c\u5c31\u662f\u5012\u6392\u7d22\u5f15\uff09\u7ec4\u6210\u3002\u6bcf\u4e2a\u6bb5\u6587\u4ef6\u5b58\u50a8\u7740\u5c31\u662f Doc \u6587\u6863\u3002<\/p>\n Lucene Index<\/strong><\/span><\/div>\n lucene \u4e2d\uff0c\u5355\u4e2a\u5012\u6392\u7d22\u5f15\u6587\u4ef6\u79f0\u4e3a segment\u3002\u5176\u4e2d\u6709\u4e00\u4e2a\u6587\u4ef6\uff0c\u8bb0\u5f55\u4e86\u6240\u6709 segments \u7684\u4fe1\u606f\uff0c\u79f0\u4e3a commit point\uff1a<\/p>\n \u6587\u6863 create \u65b0\u5199\u5165\u65f6\uff0c\u4f1a\u751f\u6210\u65b0\u7684 segment\u3002\u540c\u6837\u4f1a\u8bb0\u5f55\u5230 commit point \u91cc\u9762<\/p>\n \u6587\u6863\u67e5\u8be2\uff0c\u4f1a\u67e5\u8be2\u6240\u6709\u7684 segments<\/p>\n \u5f53\u4e00\u4e2a\u6bb5\u5b58\u5728\u6587\u6863\u88ab\u5220\u9664\uff0c\u4f1a\u7ef4\u62a4\u8be5\u4fe1\u606f\u5728 .liv \u6587\u4ef6\u91cc\u9762<\/p>\n \u65b0\u6587\u6863\u5199\u5165\u6d41\u7a0b<\/strong><\/span><\/div>\n \u65b0\u6587\u6863\u521b\u5efa\u6216\u8005\u66f4\u65b0\u65f6\uff0c\u8fdb\u884c\u5982\u4e0b\u6d41\u7a0b\uff1a<\/p>\n \u66f4\u65b0\u4e0d\u4f1a\u4fee\u6539\u539f\u6765\u7684 segment\uff0c\u66f4\u65b0\u548c\u521b\u5efa\u64cd\u4f5c\u90fd\u4f1a\u751f\u6210\u65b0\u7684\u4e00\u4e2a segment\u3002\u6570\u636e\u54ea\u91cc\u6765\u5462\uff1f\u5148\u4f1a\u5b58\u5728\u5185\u5b58\u7684 bugger \u4e2d\uff0c\u7136\u540e\u6301\u4e45\u5316\u5230 segment \u3002<\/p>\n \u6570\u636e\u6301\u4e45\u5316\u6b65\u9aa4\u5982\u4e0b\uff1awrite -> refresh -> flush -> merge<\/p>\n write \u8fc7\u7a0b<\/strong><\/span><\/div>\n \u4e00\u4e2a\u65b0\u6587\u6863\u8fc7\u6765\uff0c\u4f1a\u5b58\u50a8\u5728 in-memory buffer \u5185\u5b58\u7f13\u5b58\u533a\u4e2d\uff0c\u987a\u4fbf\u4f1a\u8bb0\u5f55 Translog\u3002<\/p>\n \u8fd9\u65f6\u5019\u6570\u636e\u8fd8\u6ca1\u5230 segment \uff0c\u662f\u641c\u4e0d\u5230\u8fd9\u4e2a\u65b0\u6587\u6863\u7684\u3002\u6570\u636e\u53ea\u6709\u88ab refresh \u540e\uff0c\u624d\u53ef\u4ee5\u88ab\u641c\u7d22\u5230\u3002\u90a3\u4e48 \u8bb2\u4e0b refresh \u8fc7\u7a0b<\/p>\n refresh \u8fc7\u7a0b<\/strong><\/span><\/div>\n refresh \u9ed8\u8ba4 1 \u79d2\u949f\uff0c\u6267\u884c\u4e00\u6b21\u4e0a\u56fe\u6d41\u7a0b\u3002ES \u662f\u652f\u6301\u4fee\u6539\u8fd9\u4e2a\u503c\u7684\uff0c\u901a\u8fc7 index.refresh_interval \u8bbe\u7f6e refresh \uff08\u51b2\u5237\uff09\u95f4\u9694\u65f6\u95f4\u3002refresh \u6d41\u7a0b\u5927\u81f4\u5982\u4e0b\uff1a<\/p>\n in-memory buffer \u4e2d\u7684\u6587\u6863\u5199\u5165\u5230\u65b0\u7684 segment \u4e2d\uff0c\u4f46 segment \u662f\u5b58\u50a8\u5728\u6587\u4ef6\u7cfb\u7edf\u7684\u7f13\u5b58\u4e2d\u3002\u6b64\u65f6\u6587\u6863\u53ef\u4ee5\u88ab\u641c\u7d22\u5230<\/p>\n \u6700\u540e\u6e05\u7a7a in-memory buffer\u3002\u6ce8\u610f: Translog \u6ca1\u6709\u88ab\u6e05\u7a7a\uff0c\u4e3a\u4e86\u5c06 segment \u6570\u636e\u5199\u5230\u78c1\u76d8<\/p>\n \u6587\u6863\u7ecf\u8fc7 refresh \u540e\uff0c segment \u6682\u65f6\u5199\u5230\u6587\u4ef6\u7cfb\u7edf\u7f13\u5b58\uff0c\u8fd9\u6837\u907f\u514d\u4e86\u6027\u80fd IO \u64cd\u4f5c\uff0c\u53c8\u53ef\u4ee5\u4f7f\u6587\u6863\u641c\u7d22\u5230\u3002refresh \u9ed8\u8ba4 1 \u79d2\u6267\u884c\u4e00\u6b21\uff0c\u6027\u80fd\u635f\u8017\u592a\u5927\u3002\u4e00\u822c\u5efa\u8bae\u7a0d\u5fae\u5ef6\u957f\u8fd9\u4e2a refresh \u65f6\u95f4\u95f4\u9694\uff0c\u6bd4\u5982 5 s\u3002\u56e0\u6b64\uff0cES \u5176\u5b9e\u5c31\u662f\u51c6\u5b9e\u65f6\uff0c\u8fbe\u4e0d\u5230\u771f\u6b63\u7684\u5b9e\u65f6\u3002<\/p>\n flush \u8fc7\u7a0b<\/strong><\/span><\/div>\n \u4e0a\u4e2a\u8fc7\u7a0b\u4e2d segment \u5728\u6587\u4ef6\u7cfb\u7edf\u7f13\u5b58\u4e2d\uff0c\u4f1a\u6709\u610f\u5916\u6545\u969c\u6587\u6863\u4e22\u5931\u3002\u90a3\u4e48\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u6587\u6863\u4e0d\u4f1a\u4e22\u5931\uff0c\u9700\u8981\u5c06\u6587\u6863\u5199\u5165\u78c1\u76d8\u3002\u90a3\u4e48\u6587\u6863\u4ece\u6587\u4ef6\u7f13\u5b58\u5199\u5165\u78c1\u76d8\u7684\u8fc7\u7a0b\u5c31\u662f flush\u3002\u5199\u5165\u6b21\u6015\u540e\uff0c\u6e05\u7a7a translog\u3002<\/p>\n translog \u4f5c\u7528\u5f88\u5927\uff1a<\/p>\n \u4fdd\u8bc1\u6587\u4ef6\u7f13\u5b58\u4e2d\u7684\u6587\u6863\u4e0d\u4e22\u5931<\/p>\n \u7cfb\u7edf\u91cd\u542f\u65f6\uff0c\u4ece translog \u4e2d\u6062\u590d<\/p>\n \u65b0\u7684 segment \u6536\u5f55\u5230 commit point \u4e2d<\/p>\n \u5177\u4f53\u53ef\u4ee5\u770b\u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/7.3\/indices-flush.html<\/p>\n merge \u8fc7\u7a0b<\/strong><\/span><\/div>\n \u4e0a\u9762\u51e0\u4e2a\u6b65\u9aa4\uff0c\u53ef\u89c1 segment \u4f1a\u8d8a\u6765\u8d8a\u591a\uff0c\u90a3\u4e48\u641c\u7d22\u4f1a\u8d8a\u6765\u8d8a\u6162\uff1f\u600e\u4e48\u5904\u7406\u5462\uff1f<\/p>\n \u901a\u8fc7 merge \u8fc7\u7a0b\u89e3\u51b3\uff1a<\/p>\n \u5c31\u662f\u5404\u4e2a\u5c0f\u6bb5\u6587\u4ef6\uff0c\u5408\u5e76\u6210\u4e00\u4e2a\u5927\u6bb5\u6587\u4ef6\u3002\u6bb5\u5408\u5e76\u8fc7\u7a0b<\/p>\n \u6bb5\u5408\u5e76\u7ed3\u675f\uff0c\u65e7\u7684\u5c0f\u6bb5\u6587\u4ef6\u4f1a\u88ab\u5220\u9664<\/p>\n .liv \u6587\u4ef6\u7ef4\u62a4\u7684\u5220\u9664\u6587\u6863\uff0c\u4f1a\u901a\u8fc7\u8fd9\u4e2a\u8fc7\u7a0b\u8fdb\u884c\u6e05\u9664<\/p>\n \u5c0f\u7ed3<\/strong><\/div>\n \u5982\u8fd9\u4e2a\u56fe\uff0cES \u5199\u5165\u539f\u7406\u4e0d\u96be\uff0c\u8bb0\u4f4f\u5173\u952e\u70b9\u5373\u53ef\u3002<\/p>\n write -> refresh -> flush<\/p>\n \u2013 write\uff1a\u6587\u6863\u6570\u636e\u5230\u5185\u5b58\u7f13\u5b58\uff0c\u5e76\u5b58\u5230 translog<\/p>\n \u2013 refresh\uff1a\u5185\u5b58\u7f13\u5b58\u4e2d\u7684\u6587\u6863\u6570\u636e\uff0c\u5230\u6587\u4ef6\u7f13\u5b58\u4e2d\u7684 segment \u3002\u6b64\u65f6\u53ef\u4ee5\u88ab\u641c\u5230<\/p>\n \u2013 flush \u662f\u7f13\u5b58\u4e2d\u7684 segment \u6587\u6863\u6570\u636e\u5199\u5165\u5230\u78c1\u76d8<\/p>\n \u5199\u5165\u7684\u539f\u7406\u544a\u8bc9\u6211\u4eec\uff0c\u8003\u8651\u7684\u70b9\u5f88\u591a\uff1a\u6027\u80fd\u3001\u6570\u636e\u4e0d\u4e22\u5931\u7b49\u7b49<\/p>\n","protected":false},"excerpt":{"rendered":" Elasticsearch \u662f\u4e00\u4e2a\u57fa\u4e8e Apache Lucene(TM) \u7684\u5f00\u6e90\u641c\u7d22\u5f15\u64ce\u3002 \u65e0\u8bba\u5728\u5f00\u6e90\u8fd8\u662f\u4e13 […]<\/p>\n","protected":false},"author":668,"featured_media":198676,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-198669","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\/198669","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\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=198669"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/198669\/revisions"}],"predecessor-version":[{"id":198677,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/198669\/revisions\/198677"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/198676"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=198669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=198669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=198669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}} |