[英]Lucene indexing and searching at the same time
I want to search with Lucene on an index. 我想用Lucene搜索索引。 The index is changed frequently.
索引经常更改。 So I need to do something to search and index at the same time.
所以我需要做一些事情来同时搜索和索引。 It's a web application on Tomcat.
它是Tomcat上的Web应用程序。 And I want to use RAMDeirectory to increase the searching speed.
我想使用RAMDeirectory来提高搜索速度。 I don't know how to do it!
我不知道怎么做!
NRTManager
in the misc
Lucene package provides the ability to search and index at the same time. misc
Lucene包中的NRTManager
提供了同时搜索和索引的功能。
TrackingIndexWriter writer; // your writer
SearcherFactory factory = new SearcherFactory();
NRTManager mgr = new NRTManager(writer, factory);
Check NRTManager methods for more info. 检查NRTManager方法以获取更多信息。
You can search and index at the same time using the same index. 您可以使用相同的索引同时搜索和索引。 Look at Lucene's near real time search .
看看Lucene的近实时搜索 。
Some example code from the wiki, 来自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);
You have to do that either doing a 你必须这样做
Depends on the requirement, what latency you need. 取决于要求,您需要什么样的延迟。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.