---------- Forwarded Message ----------
Subject: [PATCH] JDBCDirectory 0.05 Date: Thursday 21 October 2004 11:30 From: Ronald Haentjens Dekker <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]