I’m developing a Desktop Search Engine in Visual Basic 9 (VS2008) using Lucene.NET (v2.0).
I use the following code to initialize the IndexWriter
Private writer As IndexWriter writer = New IndexWriter(indexDirectory, New StandardAnalyzer(), False) writer.SetUseCompoundFile(True)
If I select the same document folder (containing files to be indexed) twice, two different entries for each file in that document folder are created in the index.
I want the IndexWriter to discard any files that are already present in the Index.
What should I do to ensure this?
To update a lucene index you need to delete the old entry and write in the new entry. So you need to use an IndexReader to find the current item, use writer to delete it and then add your new item. The same will be true for multiple entries which I think is what you are trying to do.Just find all the entries, delete them all and then write in the new entries.