I am using 1.9.1(java). I am trying to add documents to an existing index that may or may not exist. I use a RAMDirectory to build a temp index that is later merged. Before adding a new document, I search the existing index (using unique key) to see if it is there. If not, I add it.
In reading the documentation, I understood that I can search while an index is being updated. It was not clear if that search would include recently added items. I had assumed it would. However, it appears to not find them unless I close and re-open the searcher... The net result is that I get duplicate documents as the search does not find the document if I recently added it. Note that the duplicate CANNOT come from the RAMDirectory (i.e., getNewDocuments), as it is guaranteed to have no duplicates in it. The search is failing to find documents that have been recently added via a "addIndexes". Can anyone clarify this behavior, i.e., why does search not find recently added documents unless I close and re-open it? I have code that does roughly the following: RAMDirectory added = new RAMDirectory(...) IndexWriter writer = new IndexWriter(the main index); IndexWriter ramWriter = new IndexWriter(added) IndexSearcher searcher = new IndexSearcher(...) for (Document d : getNewDocuments()) { ... build a query if (searcher.search(...) == 0) { // doesn't exist, so we can add it } if (timeToMerge) { writer.addIndexes(new Directory[] {added}); added.close();se(); added = new RAMDirectory(); ramWriter.close(); ramWriter = new IndexWriter(added, new StandardAnalyzer(), true); // for some reason the searcher won't see the new indices // unless the following two lines are here searcher.close(); searcher = new IndexSearcher(current.getDirectory()); } } Jim Wilson Colorado Springs, CO 719-266-4431 (Home) 719-661-6768 (Cell) [EMAIL PROTECTED] IM:jwilsonsprings Registered Linux User # 302849 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]