我有一个索引,应该经常更新(参见Lucene indexing and searching at the same time)。因此,首先我将索引设为-1,然后将lucene IndexSearcher放在它上面。Tomcat上的web应用程序在Servlet上使用它供用户搜索。然后,我创建index-2 (更新!)。我希望将索引更改为新的索引并删除旧的索引( IndexSearcher -1),而不会在Tomcat上关闭我的web应用程序。有什么想法吗!?
发布于 2012-02-16 10:37:14
使用新的NRTManager。重新打开整个索引是不好的。
发布于 2012-02-17 03:57:37
您不需要两个索引。您只能在应用程序中使用一个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。
https://stackoverflow.com/questions/9303319
复制相似问题