Lucene does this RAM/FS stuff seamlessly for you in the background.
Just open the FSDirectory and do your indexing. If I had to guess,
though, from a quick glance, I think you should do the addIndexes
after the ramWriter close, but that's just a guess, as I haven't tried
it.
-Grant
On Aug 7, 2008, at 10:12 PM, 장용석 wrote:
hi,
I am using RamDirectory and FSDirectory for indexing documents.
I use RamDirectory as Buffer.
For example,
-----------------------------------
String indexDir = "d:/lucene_data/merge_test_index";
Analyzer analyzer = new StopAnalyzer();
RAMDirectory ramDir = new RAMDirectory();
IndexWriter ramWriter = new IndexWriter(ramDir, analyzer, true);
for (int i = 0; i < 10000; i++) {
Document doc = new Document();
doc.add(new Field("id", "test id"+i, Field.Store.YES,
Field.Index.TOKENIZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
writer.addDocument(doc);
}
IndexWriter fsWriter = new IndexWriter(indexDir, analyzer, true);
fsWriter.addIndexes(new Directory[] { ramDir });
ramWriter.close();
fsWriter.close();
------------------------------------
I know IndexWriter.addIndexes(Directory[] dir) method can merge other
indexes.
But, when I execute my program, just 2 files are created in index
directory.
(segments.gen and segments_4)
And when I open with LUKE the index then meet error , It's bad index
file.
What's wrong about that code..?
It's almost same as sample source code on book. I can't find any
reason.
Please let me know what is wrong.
Thank you.
--
DEV용식
http://devyongsik.tistory.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]