lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "xing@mac.com" <x...@mac.com>
Subject Loading FS index into RAM index
Date Sat, 09 Jul 2005 06:44:57 GMT
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: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message