Ali Hashemi
Ali Hashemi

Reputation: 3368

Changing Lucene Searcher on Running Tomcat

I have an index which should be updated so frequently (See Lucene indexing and searching at the same time). So first I make the index-1 and then put the lucene IndexSearcher on it. The web application on Tomcat uses it on the Servlet for users to search. Then, I make index-2 (updated!). I want to change the IndexSearcher to the new index and delete the old index (index-1), without downing my web application on Tomcat. Any ideas!?

Upvotes: 0

Views: 187

Answers (2)

Alexander Kuznetsov
Alexander Kuznetsov

Reputation: 3112

You don't need two indexes. You can use only one IndexWriter in application and on each new search create a IndexSearch in following way


  IndexWriter indexWriter;

  public List search(){
    IndexReader indexReader = IndexReader.open(indexWriter, false);
    IndexSearcher indexSearcher = new IndexSearcher(indexReader); 

    //do search and return answer

  }

In this case the performance will be pretty good. I used Lucene 3.5.

Upvotes: 0

MJB
MJB

Reputation: 9399

Use the new NRTManager. Reopening entire indexes is BAD.

Upvotes: 1

Related Questions