这是我在 lucene 中搜索内容的代码。
ScoreDoc[] hits = null;
StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_35);
QueryParser q = new QueryParser(Version.LUCENE_35, "content", analyzer);
Query query = q.parse(searchString);
IndexReader reader = IndexReader.open(IndexWriterSingleton.getIndexWriter(), true);
IndexSearcher is = new IndexSearcher(reader);
// IndexSearcher is = new IndexSearcher(index, true);
TopScoreDocCollector collector = TopScoreDocCollector.create(100, true);
is.search(query, collector);
hits = collector.topDocs().scoreDocs;
我的问题是:这条线(只是这条线)是否使搜索接近实时?
IndexReader reader = IndexReader.open(IndexWriterSingleton.getIndexWriter(), true);
我正在维护一个 IndexWriter(不在任何地方关闭它)。