您好我在尝试实施lucene搜索(索引)时遇到了一个奇怪的错误。
我正在做的很简单: 1.我正在初始化分析器和indexwriterconfig 2.初始化索引编写器和单个文档 3.将文档添加到索引编写器< - -breaks here!为什么....?错误
" java.lang.IllegalStateException:TokenStream合同违规: reset()/ close()调用丢失,reset()调用多次,或 子类不调用super.reset()。请参阅Javadocs TokenStream类有关正确消耗的更多信息 。工作流程"
相关代码:
Analyzer analyzer = new StandardAnalyzer(Version.LATEST);
IndexWriterConfig iwc = new IndexWriterConfig(Version.LATEST, analyzer);
//set indexing methodology
if (bCreate) {
//removing any previously indexed documents:
iwc.setOpenMode(OpenMode.CREATE);
} else {
// Add new documents to an existing index:
iwc.setOpenMode(OpenMode.CREATE_OR_APPEND);
}
IndexWriter iwWriter = new IndexWriter(FSDirectory.open(new File( strIndexPath )), iwc);
Document doc = new Document();
//Fields that are NOT searchable
doc.add(new StringField("AppID", strAppId, Field.Store.YES));
doc.add(new StringField("Url", strUrl, Field.Store.YES));
//Fields that ARE searchable
doc.add(new TextField("AppName", strAppName, Field.Store.YES));
doc.add(new TextField("AppDescription", strAppDescription, Field.Store.YES));
iwWriter.addDocument(doc); // <-- breaks here!!!