You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Ronald Haentjens Dekker <ro...@niwi.knaw.nl> on 2004/10/21 13:37:30 UTC
Fwd: [PATCH] JDBCDirectory 0.05
---------- Forwarded Message ----------
Subject: [PATCH] JDBCDirectory 0.05
Date: Thursday 21 October 2004 11:30
From: Ronald Haentjens Dekker <ro...@niwi.knaw.nl>
To: vito@mnis.com
Dear Anthony Vito,
With great interest I took notice of your implementation of a Lucene
Directory on a JDBC Connection.
I am a member of the i-Tor development team (www.i-tor.org) and would like to
use JDBCDirectory to store lucene indices on a MySQL database to improve the
scalability of the search engine.
However while running the i-Tor indexer integration test with JDBCDirectory a
bug was discovered. After writing a Lucene Document to the index and then
querying the number of documents in the index the answer was always 0.
I was able to reproduce the problem in a unit test which shows the problem:
public void testIndexWriteRead() throws SQLException, IOException {
Connection conn = connectionPool.getConnection();
JDBCDirectory index = new JDBCDirectory(conn, "site");
index.clear();
IndexWriter indexWriter = new IndexWriter(index, new
StandardAnalyzer(), !IndexReader.indexExists(index));
indexWriter.addDocument(new Document());
indexWriter.close();
IndexReader indexReader = IndexReader.open(index);
assertEquals(1 , indexReader.numDocs());
indexReader.close();
index.close();
}
The test fails because during the rename of segments.new to segments the
fileIdMap in the JDBCDirectoryManager class is not updated.
There is a simple fix for the problem:
Add the following statement at the end of the renameRows(JDBCFile oldFile,
JDBCFile newFile) method in the JDBCDirectoryManager class:
fileIdMap.put(newFile.name, new Integer(oldFile.id));
With that change the unit test passes and all the indexer integration tests
work.
I hope someone finds this contribution usefull.
Best regards,
Ronald Haentjens Dekker
-------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org