lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Taylor <>
Subject Reopening an index reader still giving me deleted records ?
Date Mon, 07 Nov 2011 13:36:50 GMT

I build indexes from scratch every three hours in a seperate process, 
then when they are built I replace the old indexes with these new ones 
in my search server.
Then I tell the search to reload the indexes as follows:

public void reloadIndex() throws CorruptIndexException, IOException {

         if (indexSearcher != null) {
             IndexReader oldReader = indexSearcher.getIndexReader();
             IndexReader newReader = oldReader.reopen();
             if (oldReader != newReader) {
                 Similarity similarity = indexSearcher.getSimilarity();
                 indexSearcher = new IndexSearcher(newReader);

What I'm finding is that new searches are finding new records added BUT 
still find records that have been deleted and no longer exist in the 
index. This is in one query, thus must mean I'm getting NEW AND OLD 
results for my
new index reader rather than still using the old one, so am I 
misunderstanding what reopen() does, or it not working correctly ?

thanks Paul

(This code is only other plaae where reader is accessed:

public Results searchLucene(String query, int offset, int limit) throws 
IOException, ParseException {

         IndexSearcher searcher=null;
         try {
             searcher = getIndexSearcher();
             TopDocs topdocs =, offset 
+ limit);
             return processResults(searcher, topdocs, offset);
         finally {

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message