我正在尝试为一堆文档创建一个索引,并在调用addDocument()时收到异常“此Analyzer已关闭”:
Analyzer an = new StandardAnalyzer(Version.LUCENE_34);
String indexDirPath = "c:/myIndexDir";
IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_34, an);
iwc.setOpenMode(OpenMode.CREATE);
Directory dir = FSDirectory.open(new File(indexDirPath));
IndexWriter writer = new IndexWriter(dir, iwc);
Document doc = new Document();
...
writer.addDocument(doc);
我认为它在抱怨分析仪,但为什么呢?这是确切的信息:
org.apache.lucene.store.AlreadyClosedException: this Analyzer is closed