I had a question now, this one regarding lucene. I was trying to make a lucene source code that can do indexing and store them first in a memory using RAMDirectory and then
I'm not really sure that you'll get any performance gain from doing this, but you could do all the indexing on a RAMDirectory
and then copy the directory to an FSDirectory.
Like this:
private int index(File indexDir, File dataDir, String suffix) throws Exception {
RAMDirectory ramDir = new RAMDirectory(); // 1
IndexWriter indexWriter = new IndexWriter(
ramDir, // 2
new SimpleAnalyzer(),
true,
IndexWriter.MaxFieldLength.LIMITED);
indexWriter.setUseCompoundFile(false);
indexDirectory(indexWriter, dataDir, suffix);
int numIndexed = indexWriter.maxDoc();
indexWriter.optimize();
indexWriter.close();
Directory.copy(ramDir, FSDirectory.open(indexDir), false); // 3
return numIndexed;
}