lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joseph Wilkicki" <jwilki...@contextmedia.com>
Subject Error merging indices with Lucene 1.3 RC1
Date Tue, 19 Aug 2003 21:42:44 GMT
Hi all!

I am working with Lucene 1.3 RC1 and found what I think is a problem.
Basically, I am indexing into a RAMDirectory and then using addIndexes to
merge the RAMDirectory into a file system index.  Adding in a small
number of documents doesn't seem to work.

My test code is like this:

		Directory memDir = new RAMDirectory();

		File tempDir = new File(System.getProperty("user.dir"), "test2");
		Directory fsDir = FSDirectory.getDirectory(tempDir, true);

		IndexWriter fsWriter =
			new IndexWriter(fsDir, new StandardAnalyzer(), true);

		IndexWriter memWriter =
			new IndexWriter(memDir, new StandardAnalyzer(), true);

		Document toAdd1 = createADocument(); // creates a random document
		Document toAdd2 = createADocument();

		memWriter.addDocument(toAdd1);
		memWriter.addDocument(toAdd2);

	      String[] files = memDir.list();
	      for(int i=0;i<1;i++){
              System.out.println(files[i]); // Only lists "segments" file,
no data files
            }

		fsWriter.addIndexes(new Directory[] { memDir });

		fsWriter.close();

		IndexReader reader =
			IndexReader.open(FSDirectory.getDirectory(tempDir, false));

            Document toCompare = reader.document(1); // Results in
ArrayIndexOutofBoundsException

		reader.close();
		tempDir.delete();

I should be able to get the document at index 1, but it fails.  If I add in
12 documents by doing this:

memWriter.addDocument(toAdd1);
memWriter.addDocument(toAdd2);

for(int i=0;i<10;i++){
	memWriter.addDocument(createADocument());
}

I only see 10 documents returned by IndexReader.termDocs(Term) on the
FSDirectory after I merge the RAMDirectory in.  Any insights on why this may
be?  Am I doing something wrong in this code?

Thanks in advance for any insights.

Joe W.


Mime
View raw message