@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索引合并
最新推荐文章于 2020-12-23 09:38:22 发布