lucene 索引最佳化

來源:互聯網
上載者:User

標籤:最佳化   配置   java   調試   img   搜尋   epo   技術   cee   

今天用了lukeall裡面的一個功能optimize也就是索引最佳化,

發現有花時間比較長但是最佳化結果比較好,

索引裡面的所有段檔案都merge到一個段檔案裡去了,

於是自己就試了一下,雖然沒有lukeall最佳化的好,

但起碼比之前幾百個碎檔案要好的多了下面是代碼,lucene用的是4.8 當然也可以用lukeall去最佳化,但是你得找到一個版本和索引版本一致的lukeall ,或者搜尋版本>lukeall版本>索引版本(得用三套才行 太麻煩了)

根據方法名稱大致就能知道是什麼意思(其實我也有好多意思不知道 哈哈 ^_^)
IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_48,analyzer);ConcurrentMergeScheduler scheduler = new ConcurrentMergeScheduler();scheduler.setMaxMergesAndThreads(2, 1);scheduler.setMergeThreadPriority(1);TieredMergePolicy policy = new TieredMergePolicy();policy.setMaxMergeAtOnce(10);policy.setMaxMergeAtOnceExplicit(30);policy.setMaxMergedSegmentMB(5120);//根據自己電腦配置設定policy.setFloorSegmentMB(2);policy.setForceMergeDeletesPctAllowed(10);policy.setSegmentsPerTier(10.0);policy.setMaxCFSSegmentSizeMB(8 * 1024);//根據自己電腦配置設定policy.setNoCFSRatio(1);conf.setRAMBufferSizeMB(16);conf.setMaxBufferedDocs(-1);conf.setReaderTermsIndexDivisor(1);conf.setTermIndexInterval(128);conf.setMergeScheduler(scheduler);conf.setMergePolicy(policy);conf.setUseCompoundFile(true);

  

 

這是之前的,

這是剛出爐的

少了很多碎檔案,我知道肯定還能最佳化的更完美,目前來說我只能最佳化這麼多,以後慢慢調試最佳化。。

lucene 索引最佳化

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.