Search in sources :

Example 1 with HardlinkCopyDirectoryWrapper

use of org.apache.lucene.store.HardlinkCopyDirectoryWrapper in project lucene-solr by apache.

the class IndexMergeTool method main.

public static void main(String[] args) throws IOException {
    if (args.length < 3) {
        System.err.println("Usage: IndexMergeTool <mergedIndex> <index1> <index2> [index3] ...");
        System.exit(1);
    }
    FSDirectory mergedIndex = FSDirectory.open(Paths.get(args[0]));
    IndexWriter writer = new IndexWriter(mergedIndex, new IndexWriterConfig(null).setOpenMode(OpenMode.CREATE));
    Directory[] indexes = new Directory[args.length - 1];
    for (int i = 1; i < args.length; i++) {
        // try to use hardlinks if possible
        indexes[i - 1] = new HardlinkCopyDirectoryWrapper(FSDirectory.open(Paths.get(args[i])));
    }
    System.out.println("Merging...");
    writer.addIndexes(indexes);
    System.out.println("Full merge...");
    writer.forceMerge(1);
    writer.close();
    System.out.println("Done.");
}
Also used : IndexWriter(org.apache.lucene.index.IndexWriter) FSDirectory(org.apache.lucene.store.FSDirectory) HardlinkCopyDirectoryWrapper(org.apache.lucene.store.HardlinkCopyDirectoryWrapper) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) Directory(org.apache.lucene.store.Directory) FSDirectory(org.apache.lucene.store.FSDirectory)

Aggregations

IndexWriter (org.apache.lucene.index.IndexWriter)1 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)1 Directory (org.apache.lucene.store.Directory)1 FSDirectory (org.apache.lucene.store.FSDirectory)1 HardlinkCopyDirectoryWrapper (org.apache.lucene.store.HardlinkCopyDirectoryWrapper)1