Lucene:为什么我在尝试创建索引时“关闭此分析器”?

时间:2012-02-16 20:24:29

标签: lucene indexing analyzer

我正在尝试为一堆文档创建一个索引,并在调用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

0 个答案:

没有答案