[英]Lucene indexing and searching at the same time
我想用Lucene搜索索引。 索引经常更改。 所以我需要做一些事情来同时搜索和索引。 它是Tomcat上的Web应用程序。 我想使用RAMDeirectory来提高搜索速度。 我不知道怎么做!
misc
Lucene包中的NRTManager
提供了同时搜索和索引的功能。
TrackingIndexWriter writer; // your writer
SearcherFactory factory = new SearcherFactory();
NRTManager mgr = new NRTManager(writer, factory);
检查NRTManager方法以获取更多信息。
您可以使用相同的索引同时搜索和索引。 看看Lucene的近实时搜索 。
来自wiki的一些示例代码,
IndexWriter writer; // create an IndexWriter here
Document doc = null; // create a document here
writer.addDocument(doc); // update a document
IndexReader reader = writer.getReader(); // get a reader with the new doc
Document addedDoc = reader.document(0);
你必须这样做
取决于要求,您需要什么样的延迟。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.