lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Is there a tool that merges Lucene indexes?
Date Thu, 17 Nov 2005 11:56:33 GMT

On 17 Nov 2005, at 03:37, Oren Shir wrote:
> Does Luke, Lucli, or any of the existing tools enable merging Lucene
> indexes?

No, none of those tools do it, but it is all of about 10 lines of code:

public class IndexMergeTool {
   public static void main(String[] args) throws IOException {
     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);
     }

     writer.addIndexes(indexes);

     writer.optimize();
     writer.close();
   }
}

We could add this to contrib/utils or something, possibly.

     Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message