You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Otis Gospodnetic <ot...@yahoo.com> on 2005/12/21 01:05:46 UTC

Re: Is there a tool that merges Lucene indexes?

Just added it.

Otis

----- Original Message ----
From: Erik Hatcher <er...@ehatchersolutions.com>
To: java-user@lucene.apache.org
Sent: Thu 17 Nov 2005 06:56:33 AM EST
Subject: Re: Is there a tool that merges Lucene indexes?


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





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