{"id":1837,"date":"2017-08-22T17:35:16","date_gmt":"2017-08-22T09:35:16","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=1837"},"modified":"2017-08-22T17:38:00","modified_gmt":"2017-08-22T09:38:00","slug":"%e8%a7%a3%e5%89%96-lucene-%e7%9a%84%e6%80%bb%e4%bd%93%e6%9e%b6%e6%9e%84","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=1837","title":{"rendered":"\u89e3\u5256 Lucene \u7684\u603b\u4f53\u67b6\u6784"},"content":{"rendered":"<p>\n\t<a href=\"http:\/\/www.xttblog.com\/?tag=Lucene\" name=\"Lucene\" target=\"_blank\" title=\"Lucene\">Lucene<\/a> \u4f7f\u7528\u8d77\u6765\u5f88\u7b80\u5355\uff0c\u4f46\u662f\u8981\u641e\u61c2\u5b83\u5185\u90e8\u7684\u4e00\u4e9b\u7b97\u6cd5\u5c31\u5f88\u96be\u4e86\u3002\u672c\u6587\u5c06\u4ece Lucene \u7684\u67b6\u6784\u56fe\u6765\u4ecb\u7ecd Lucene \u7684\u7279\u70b9\u548c\u5e38\u7528\u5305\u3002\n<\/p>\n<p>\n\tLucene\u603b\u7684\u6765\u8bf4\u662f\uff1a\n<\/p>\n<ul>\n<li>\n\t\t\u4e00\u4e2a\u9ad8\u6548\u7684\uff0c\u53ef\u6269\u5c55\u7684\uff0c\u5168\u6587\u68c0\u7d22\u5e93\u3002\n\t<\/li>\n<li>\n\t\t\u5168\u90e8\u7528Java\u5b9e\u73b0\uff0c\u65e0\u987b\u914d\u7f6e\u3002\n\t<\/li>\n<li>\n\t\t\u4ec5\u652f\u6301\u7eaf\u6587\u672c\u6587\u4ef6\u7684\u7d22\u5f15(Indexing)\u548c\u641c\u7d22(Search)\u3002\n\t<\/li>\n<li>\n\t\t\u4e0d\u8d1f\u8d23\u7531\u5176\u4ed6\u683c\u5f0f\u7684\u6587\u4ef6\u62bd\u53d6\u7eaf\u6587\u672c\u6587\u4ef6\uff0c\u6216\u4ece\u7f51\u7edc\u4e2d\u6293\u53d6\u6587\u4ef6\u7684\u8fc7\u7a0b\u3002\n\t<\/li>\n<\/ul>\n<p>\n\tLucene \u7684\u6784\u67b6\u548c\u8fc7\u7a0b\u5982\u4e0b\u56fe\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"Lucene \u67b6\u6784\u56fe\" src=\"http:\/\/ocuzluml6.bkt.clouddn.com\/lucene001.jpg\" style=\"width: 708px;height: 575px\" \/>\n<\/p>\n<p>\n\t\u8bf4\u660e Lucene \u662f\u6709\u7d22\u5f15\u548c\u641c\u7d22\u7684\u4e24\u4e2a\u8fc7\u7a0b\uff0c\u5305\u542b\u7d22\u5f15\u521b\u5efa\uff0c\u7d22\u5f15\uff0c\u641c\u7d22\u4e09\u4e2a\u8981\u70b9\u3002\n<\/p>\n<p>\n\t\u4e0b\u9762\u662f\u4e00\u4e9b Lucene \u7684\u5404\u7ec4\u4ef6\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"Lucene \u7684\u7ec4\u4ef6\" src=\"http:\/\/hi.csdn.net\/attachment\/201002\/1\/3634917_1265049062fG9p.jpg\" style=\"width: 504px;height: 326px\" \/>\n<\/p>\n<ul>\n<li>\n\t\t\u88ab\u7d22\u5f15\u7684\u6587\u6863\u7528Document\u5bf9\u8c61 \u8868\u793a\u3002\n\t<\/li>\n<li>\n\t\tIndexWriter \u901a\u8fc7\u51fd\u6570addDocument \u5c06\u6587\u6863\u6dfb\u52a0\u5230\u7d22\u5f15\u4e2d\uff0c\u5b9e\u73b0\u521b\u5efa\u7d22\u5f15\u7684\u8fc7\u7a0b\u3002\n\t<\/li>\n<li>\n\t\tLucene \u7684\u7d22\u5f15\u662f\u5e94\u7528\u53cd\u5411\u7d22\u5f15\u3002\n\t<\/li>\n<li>\n\t\t\u5f53\u7528\u6237\u6709\u8bf7\u6c42\u65f6\uff0cQuery \u4ee3\u8868\u7528\u6237\u7684\u67e5\u8be2\u8bed\u53e5\u3002\n\t<\/li>\n<li>\n\t\tIndexSearcher \u901a\u8fc7\u51fd\u6570search \u641c\u7d22Lucene Index \u3002\n\t<\/li>\n<li>\n\t\tIndexSearcher \u8ba1\u7b97term weight \u548cscore \u5e76\u4e14\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u7528\u6237\u3002\n\t<\/li>\n<li>\n\t\t\u8fd4\u56de\u7ed9\u7528\u6237\u7684\u6587\u6863\u96c6\u5408\u7528TopDocsCollector \u8868\u793a\u3002\n\t<\/li>\n<\/ul>\n<p>\n\t\u90a3\u4e48\u5982\u4f55\u5e94\u7528\u8fd9\u4e9b\u7ec4\u4ef6\u5462\uff1f\n<\/p>\n<p>\n\t\u770b\u4e0b\u9762\u8be6\u7ec6\u7684 Lucene API \u7684\u8c03\u7528\u5b9e\u73b0\u7d22\u5f15\u548c\u641c\u7d22\u8fc7\u7a0b\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"Lucene \u7684\u6267\u884c\u8fc7\u7a0b\" src=\"http:\/\/hi.csdn.net\/attachment\/201002\/1\/3634917_12650490643655.jpg\" style=\"width: 504px;height: 615px\" \/>\n<\/p>\n<h2>\n\t\u7d22\u5f15\u8fc7\u7a0b<br \/>\n<\/h2>\n<ul>\n<li>\n\t\t\u521b\u5efa\u4e00\u4e2aIndexWriter \u7528\u6765\u5199\u7d22\u5f15\u6587\u4ef6\uff0c\u5b83\u6709\u51e0\u4e2a\u53c2\u6570\uff0cINDEX_DIR \u5c31\u662f\u7d22\u5f15\u6587\u4ef6\u6240\u5b58\u653e\u7684\u4f4d\u7f6e\uff0cAnalyzer \u4fbf\u662f\u7528\u6765\u5bf9\u6587\u6863\u8fdb\u884c\u8bcd\u6cd5\u5206\u6790\u548c\u8bed\u8a00\u5904\u7406\u7684\u3002\n\t<\/li>\n<li>\n\t\t\u521b\u5efa\u4e00\u4e2aDocument \u4ee3\u8868\u6211\u4eec\u8981\u7d22\u5f15\u7684\u6587\u6863\u3002\n\t<\/li>\n<li>\n\t\t\u5c06\u4e0d\u540c\u7684Field \u52a0\u5165\u5230\u6587\u6863\u4e2d\u3002\u6211\u4eec\u77e5\u9053\uff0c\u4e00\u7bc7\u6587\u6863\u6709\u591a\u79cd\u4fe1\u606f\uff0c\u5982\u9898\u76ee\uff0c\u4f5c\u8005\uff0c\u4fee\u6539\u65f6\u95f4\uff0c\u5185\u5bb9\u7b49\u3002\u4e0d\u540c\u7c7b\u578b\u7684\u4fe1\u606f\u7528\u4e0d\u540c\u7684Field \u6765\u8868\u793a\uff0c\u5728\u672c\u4f8b\u5b50\u4e2d\uff0c\u4e00\u5171\u6709\u4e24\u7c7b\u4fe1\u606f\u8fdb\u884c\u4e86\u7d22\u5f15\uff0c\u4e00\u4e2a\u662f\u6587\u4ef6\u8def\u5f84\uff0c\u4e00\u4e2a\u662f\u6587\u4ef6\u5185\u5bb9\u3002\u5176\u4e2dFileReader \u7684SRC_FILE \u5c31\u8868\u793a\u8981\u7d22\u5f15\u7684\u6e90\u6587\u4ef6\u3002\n\t<\/li>\n<li>\n\t\tIndexWriter \u8c03\u7528\u51fd\u6570addDocument \u5c06\u7d22\u5f15\u5199\u5230\u7d22\u5f15\u6587\u4ef6\u5939\u4e2d\u3002\n\t<\/li>\n<\/ul>\n<h2>\n\t\u641c\u7d22\u8fc7\u7a0b<br \/>\n<\/h2>\n<ul>\n<li>\n\t\tIndexReader \u5c06\u78c1\u76d8\u4e0a\u7684\u7d22\u5f15\u4fe1\u606f\u8bfb\u5165\u5230\u5185\u5b58\uff0cINDEX_DIR \u5c31\u662f\u7d22\u5f15\u6587\u4ef6\u5b58\u653e\u7684\u4f4d\u7f6e\u3002\n\t<\/li>\n<li>\n\t\t\u521b\u5efaIndexSearcher \u51c6\u5907\u8fdb\u884c\u641c\u7d22\u3002\n\t<\/li>\n<li>\n\t\t\u521b\u5efaAnalyer \u7528\u6765\u5bf9\u67e5\u8be2\u8bed\u53e5\u8fdb\u884c\u8bcd\u6cd5\u5206\u6790\u548c\u8bed\u8a00\u5904\u7406\u3002\n\t<\/li>\n<li>\n\t\t\u521b\u5efaQueryParser \u7528\u6765\u5bf9\u67e5\u8be2\u8bed\u53e5\u8fdb\u884c\u8bed\u6cd5\u5206\u6790\u3002\n\t<\/li>\n<li>\n\t\tQueryParser \u8c03\u7528parser \u8fdb\u884c\u8bed\u6cd5\u5206\u6790\uff0c\u5f62\u6210\u67e5\u8be2\u8bed\u6cd5\u6811\uff0c\u653e\u5230Query \u4e2d\u3002\n\t<\/li>\n<li>\n\t\tIndexSearcher \u8c03\u7528search \u5bf9\u67e5\u8be2\u8bed\u6cd5\u6811Query \u8fdb\u884c\u641c\u7d22\uff0c\u5f97\u5230\u7ed3\u679cTopScoreDocCollector \u3002\n\t<\/li>\n<\/ul>\n<p>\n\t\u4ee5\u4e0a\u4fbf\u662fLucene API\u51fd\u6570\u7684\u7b80\u5355\u8c03\u7528\u3002\n<\/p>\n<p>\n\t\u7136\u800c\u5f53\u8fdb\u5165Lucene\u7684\u6e90\u4ee3\u7801\u540e\uff0c\u53d1\u73b0Lucene\u6709\u5f88\u591a\u5305\uff0c\u5173\u7cfb\u9519\u7efc\u590d\u6742\u3002\n<\/p>\n<p>\n\t\u7136\u800c\u901a\u8fc7\u4e0b\u56fe\uff0c\u6211\u4eec\u4e0d\u96be\u53d1\u73b0\uff0cLucene\u7684\u5404\u6e90\u7801\u6a21\u5757\uff0c\u90fd\u662f\u5bf9\u666e\u901a\u7d22\u5f15\u548c\u641c\u7d22\u8fc7\u7a0b\u7684\u4e00\u79cd\u5b9e\u73b0\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"Lucene\u5b9e\u73b0\u7684\u5305\u7ed3\u6784\" src=\"http:\/\/hi.csdn.net\/attachment\/201002\/1\/3634917_12650490657464.jpg\" style=\"width: 504px;height: 329px\" \/>\n<\/p>\n<ul>\n<li>\n\t\torg.apache.lucene.document\uff1a\u8fd9\u4e2a\u5305\u63d0\u4f9b\u4e86\u4e00\u4e9b\u4e3a\u5c01\u88c5\u8981\u7d22\u5f15\u7684\u6587\u6863\u6240\u9700\u8981\u7684\u7c7b\uff0c\u6bd4\u5982 Document, Field\u3002\u8fd9\u6837\uff0c\u6bcf\u4e00\u4e2a\u6587\u6863\u6700\u7ec8\u88ab\u5c01\u88c5\u6210\u4e86\u4e00\u4e2a Document \u5bf9\u8c61\u3002\n\t<\/li>\n<li>\n\t\torg.apache.lucene.analysis\uff1a\u8fd9\u4e2a\u5305\u4e3b\u8981\u529f\u80fd\u662f\u5bf9\u6587\u6863\u8fdb\u884c\u5206\u8bcd\uff0c\u56e0\u4e3a\u6587\u6863\u5728\u5efa\u7acb\u7d22\u5f15\u4e4b\u524d\u5fc5\u987b\u8981\u8fdb\u884c\u5206\u8bcd\uff0c\u6240\u4ee5\u8fd9\u4e2a\u5305\u7684\u4f5c\u7528\u53ef\u4ee5\u770b\u6210\u662f\u4e3a\u5efa\u7acb\u7d22\u5f15\u505a\u51c6\u5907\u5de5\u4f5c\u3002\n\t<\/li>\n<li>\n\t\torg.apache.lucene.index\uff1a\u8fd9\u4e2a\u5305\u63d0\u4f9b\u4e86\u4e00\u4e9b\u7c7b\u6765\u534f\u52a9\u521b\u5efa\u7d22\u5f15\u4ee5\u53ca\u5bf9\u521b\u5efa\u597d\u7684\u7d22\u5f15\u8fdb\u884c\u66f4\u65b0\u3002\u8fd9\u91cc\u9762\u6709\u4e24\u4e2a\u57fa\u7840\u7684\u7c7b\uff1aIndexWriter \u548c IndexReader\uff0c\u5176\u4e2d IndexWriter \u662f\u7528\u6765\u521b\u5efa\u7d22\u5f15\u5e76\u6dfb\u52a0\u6587\u6863\u5230\u7d22\u5f15\u4e2d\u7684\uff0cIndexReader \u662f\u7528\u6765\u5220\u9664\u7d22\u5f15\u4e2d\u7684\u6587\u6863\u7684\u3002\n\t<\/li>\n<li>\n\t\torg.apache.lucene.search\uff1a\u8fd9\u4e2a\u5305\u63d0\u4f9b\u4e86\u5bf9\u5728\u5efa\u7acb\u597d\u7684\u7d22\u5f15\u4e0a\u8fdb\u884c\u641c\u7d22\u6240\u9700\u8981\u7684\u7c7b\u3002\u6bd4\u5982 IndexSearcher \u548c Hits, IndexSearcher \u5b9a\u4e49\u4e86\u5728\u6307\u5b9a\u7684\u7d22\u5f15\u4e0a\u8fdb\u884c\u641c\u7d22\u7684\u65b9\u6cd5\uff0cHits \u7528\u6765\u4fdd\u5b58\u641c\u7d22\u5f97\u5230\u7684\u7ed3\u679c\u3002\n\t<\/li>\n<li>\n\t\tLucene \u7684analysis \u6a21\u5757\u4e3b\u8981\u8d1f\u8d23\u8bcd\u6cd5\u5206\u6790\u53ca\u8bed\u8a00\u5904\u7406\u800c\u5f62\u6210Term \u3002\n\t<\/li>\n<li>\n\t\tLucene \u7684index \u6a21\u5757\u4e3b\u8981\u8d1f\u8d23\u7d22\u5f15\u7684\u521b\u5efa\uff0c\u91cc\u9762\u6709IndexWriter \u3002\n\t<\/li>\n<li>\n\t\tLucene \u7684store \u6a21\u5757\u4e3b\u8981\u8d1f\u8d23\u7d22\u5f15\u7684\u8bfb\u5199\u3002\n\t<\/li>\n<li>\n\t\tLucene \u7684QueryParser \u4e3b\u8981\u8d1f\u8d23\u8bed\u6cd5\u5206\u6790\u3002\n\t<\/li>\n<li>\n\t\tLucene \u7684search \u6a21\u5757\u4e3b\u8981\u8d1f\u8d23\u5bf9\u7d22\u5f15\u7684\u641c\u7d22\u3002\n\t<\/li>\n<li>\n\t\tLucene \u7684similarity \u6a21\u5757\u4e3b\u8981\u8d1f\u8d23\u5bf9\u76f8\u5173\u6027\u6253\u5206\u7684\u5b9e\u73b0\u3002\n\t<\/li>\n<\/ul>\n<p>\n\t\u4ee5\u4e0a\u5c31\u662f Lucene \u7684\u603b\u4f53\u67b6\u6784\u3002\u770b\u8d77\u6765\u5f88\u7b80\u5355\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\u7528\u5230\u7684\u7b97\u6cd5\u5f88\u591a\u3002\u8fd9\u4e2a\u6211\u4eec\u4ee5\u540e\u518d\u6162\u6162\u7684\u5b66\u4e60\uff01\n<\/p>\n<h2>\n\t\u53c2\u8003\u8d44\u6599<br \/>\n<\/h2>\n<ul>\n<li>\n\t\t<a href=\"http:\/\/www.lucene.com.cn\/about.htm\" name=\"\u5f00\u653e\u6e90\u4ee3\u7801\u7684\u5168\u6587\u68c0\u7d22\u5f15\u64ceLucene\" target=\"_blank\" title=\"\u5f00\u653e\u6e90\u4ee3\u7801\u7684\u5168\u6587\u68c0\u7d22\u5f15\u64ceLucene\">\u5f00\u653e\u6e90\u4ee3\u7801\u7684\u5168\u6587\u68c0\u7d22\u5f15\u64ceLucene<\/a>\n\t<\/li>\n<\/ul>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=1837\">\u89e3\u5256 Lucene \u7684\u603b\u4f53\u67b6\u6784<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>Lucene \u4f7f\u7528\u8d77\u6765\u5f88\u7b80\u5355\uff0c\u4f46\u662f\u8981\u641e\u61c2\u5b83\u5185\u90e8\u7684\u4e00\u4e9b\u7b97\u6cd5\u5c31\u5f88\u96be\u4e86\u3002\u672c\u6587\u5c06\u4ece Lucene \u7684\u67b6\u6784\u56fe\u6765\u4ecb\u7ecd Lu [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1444,1446,1453,1445,1456],"class_list":["post-1837","post","type-post","status-publish","format-standard","hentry","category-java","tag-lucene","tag-lucene-","tag-1453","tag-1445","tag-1456"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1837","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1837"}],"version-history":[{"count":2,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1837\/revisions"}],"predecessor-version":[{"id":1840,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1837\/revisions\/1840"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}