I was reading the Lucene book and came across the part where the author detailed how to write index to ram dir and then flush it to file dir.

That turned on a light bulb and I want to do bidirectional index loading. Build index in ram, store in file for backup. Then if I have to shutdown the process, I can then ask it to reload the index from file back into ram for searching duties.

Unforunately my code below which tries to load fs index into ram fails right at "ram_writer.addIndexes(fs_dir);" with io exception. When I check "/tmp/lucene-index/", which contains a proper index, after the io exception everything was erased and the directory was empty.

Thanks for any pointers.

Xing


try {
                System.out.println("start");
//IndexWriter file_writer = new IndexWriter("/tmp/lucene-index/", new StandardAnalyzer(), true); IndexWriter ram_writer = new IndexWriter(new RAMDirectory(), new StandardAnalyzer(), true);
                System.out.println("loaded ram_writer");
                
                Directory[] fs_dir = new Directory[1];
                
                fs_dir[0] = FSDirectory.getDirectory("/tmp/lucene-index/", 
true);
                System.out.println("loaded fs_dir");
                
                ram_writer.addIndexes(fs_dir);
                System.out.println("load fs_dir into ram");
                
                ram_writer.optimize();
                System.out.println("optimize ram index");
                
                ram_writer.close();
                //index_writer.close();
                
                System.out.println("good");
                }
                catch (IOException ex) {
                        System.out.println("io exception");
                        
                }       

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to