FileDocCategorySizeDatePackage
IndexMergeTool.javaAPI DocApache Lucene 1.91795Mon Feb 20 09:18:28 GMT 2006org.apache.lucene.misc

IndexMergeTool

public class IndexMergeTool extends Object
Merges indices specified on the command line into the index specified as the first command line argument.
author
Erik Hatcher
version
$Id$

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    if (args.length < 3) {
      System.err.println("Usage: IndexMergeTool <mergedIndex> <index1> <index2> [index3] ...");
      System.exit(1);
    }
    File mergedIndex = new File(args[0]);

    IndexWriter writer = new IndexWriter(mergedIndex, new  SimpleAnalyzer(), true);

    Directory[] indexes = new Directory[args.length - 1];
    for (int i = 1; i < args.length; i++) {
      indexes[i  - 1] = FSDirectory.getDirectory(args[i], false);
    }

    System.out.println("Merging...");
    writer.addIndexes(indexes);

    System.out.println("Optimizing...");
    writer.optimize();
    writer.close();
    System.out.println("Done.");