In order to keep my index up to date, I need to add / modify my search index every 5 minutes. The way I have it set up is with 2 indexes, one in the Full directory and one in the Incremental directory, and to search them I am using a MultiSearcher.
I am now writing a process to maintain the index. What I am doing is passing the last index date to a stored procedure and the DB is returning all new / modified records based on an "UpdatedOn" field in the DB. I then loop through the 2 directories, opening an IndexReader for each directory and deleting the document based on a TermQuery for the primary key. I then add the records to the incremental index using an IndexWriter and optimize it.
What's happening when I do subsequent searches though is that records that I know are in the index are not being returned.
Am I doing the index maintenance wrong?