0
這是我的代碼在lucene中搜索的東西。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;
我的問題是:這是否行(JUST此行)使得近實時搜索?
IndexReader reader = IndexReader.open(IndexWriterSingleton.getIndexWriter(), true);
我維護一個IndexWriter(不關閉它在任何地方)。