我有一个应该经常更新的索引(参见Lucene indexing and searching at the same time)。所以首先我创建index-1然后将lucene IndexSearcher放在上面。 Tomcat上的Web应用程序在Servlet上使用它来供用户搜索。然后,我做了index-2(更新了!)。我想将IndexSearcher更改为新索引并删除旧索引(index-1),而不是在Tomcat上关闭我的Web应用程序。任何想法!?
答案 0 :(得分:1)
使用新的NRTManager。重新打开整个索引是不好的。
答案 1 :(得分:0)
您不需要两个索引。您只能在应用程序中使用一个IndexWriter,并且在每个新搜索中都可以按以下方式创建IndexSearch
IndexWriter indexWriter;
public List search(){
IndexReader indexReader = IndexReader.open(indexWriter, false);
IndexSearcher indexSearcher = new IndexSearcher(indexReader);
//do search and return answer
}
在这种情况下,表现会非常好。我使用了Lucene 3.5。