Lucene索引合并
Posted esc_ai
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Lucene索引合并相关的知识,希望对你有一定的参考价值。
@Test
public void mergeIndex() throws IOException
Analyzer analyzer=new HanLPAnalyzer();
IndexWriterConfig icw = new IndexWriterConfig(analyzer);
icw.setOpenMode(IndexWriterConfig.OpenMode.APPEND);
String indexPath1="/Users/pan/Documents/indices1";
String indexPath2="/Users/pan/Documents/indices2";
Directory dir1=FSDirectory.open(Paths.get(new File(indexPath1).toURI()));
IndexWriter indexWriter1=new IndexWriter(dir1,icw);
FSDirectory dir2=FSDirectory.open(Paths.get(new File(indexPath2).toURI()));
FSDirectory[] fsDirectories=dir2;
indexWriter1.addIndexes(fsDirectories);
indexWriter1.close();
以上是关于Lucene索引合并的主要内容,如果未能解决你的问题,请参考以下文章