使用Lucene NRT进行搜索

时间:2019-03-29 18:41:09

标签: java lucene

我有一个服务可以实时索引新文档,同时我还有另一个应用程序可以在该索引中进行搜索, 我在索引时使用NRT,并在完成索引后关闭IndexWriter 对于搜索,请使用IndexSearcher

// for writer in a process like a service
dir = FSDirectory.open(Paths.get(indexPath));
NRTCachingDirectory cachedFSDir = new NRTCachingDirectory(dir, 10.0, 80.0);
analyzer = new SpanishAnalyzer();
iwc = new IndexWriterConfig(analyzer);
iwc.setOpenMode(OpenMode.CREATE_OR_APPEND);
iwc.setRAMBufferSizeMB(512.0);
writer = new IndexWriter(cachedFSDir, iwc);
...
// closing
writer.close();

// for searching in another process (my gui application)
reader = DirectoryReader.open(FSDirectory.open(Paths.get(indexPath)));
searcher = new IndexSearcher(reader);
...
// closing
reader.close();

,但是即使添加了新文档,它也不会检索它, 也有一些NRT可供搜索??

0 个答案:

没有答案