Solr4.8.0源碼分析(13)之LuceneCore的索引修複

來源:互聯網
上載者:User

標籤:Lucene   style   blog   color   io   os   ar   使用   java   

Solr4.8.0源碼分析(13)之LuceneCore的索引修複

題記:今天在公司研究elasticsearch,突然看到一篇部落格說elasticsearch具有索引修複功能,頓感好奇,於是點進去看了下,發現原來是Lucene Core內建的功能,於是就回家先學習下,正好也跟之前看的索引檔案的格式相應。有空也研究下Lucene的一些小工具。

 

索引的修複主要是用到CheckIndex.java這個類,可以直接查看類的Main函數來瞭解下。

1. CheckIndex的使用

首先使用以下命令來查看lucenecore.jar怎麼使用:

 1 192:lib rcf$ java -cp lucene-core-4.8-SNAPSHOT.jar -ea:org.apache.lucene... org.apache.lucene.index.CheckIndex  2  3 ERROR: index path not specified 4  5 Usage: java org.apache.lucene.index.CheckIndex pathToIndex [-fix] [-crossCheckTermVectors] [-segment X] [-segment Y] [-dir-impl X] 6  7   -fix: actually write a new segments_N file, removing any problematic segments 8   -crossCheckTermVectors: verifies that term vectors match postings; THIS IS VERY SLOW! 9   -codec X: when fixing, codec to write the new segments_N file with10   -verbose: print additional details11   -segment X: only check the specified segments.  This can be specified multiple12               times, to check more than one segment, eg ‘-segment _2 -segment _a‘.13               You can‘t use this with the -fix option14   -dir-impl X: use a specific FSDirectory implementation. If no package is specified the org.apache.lucene.store package will be used.15 16 **WARNING**: -fix should only be used on an emergency basis as it will cause17 documents (perhaps many) to be permanently removed from the index.  Always make18 a backup copy of your index before running this!  Do not run this tool on an index19 that is actively being written to.  You have been warned!20 21 Run without -fix, this tool will open the index, report version information22 and report any exceptions it hits and what action it would take if -fix were23 specified.  With -fix, this tool will remove any segments that have issues and24 write a new segments_N file.  This means all documents contained in the affected25 segments will be removed.26 27 This tool exits with exit code 1 if the index cannot be opened or has any28 corruption, else 0.

當敲java -cp lucene-core-4.8-SNAPSHOT.jar -ea:org.apache.lucene... org.apache.lucene.index.CheckIndex 這個就能看到相當於help的資訊啦,但是為什麼這裡用這麼一串奇怪的命令呢?

今天太晚了,明天繼續學習

Solr4.8.0源碼分析(13)之LuceneCore的索引修複

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.