1.线程中定义共享 IndexWriter
private static IndexWriter indexWriter = null;
Analyzer analyzer = new org.wltea.analyzer.lucene.IKAnalyzer();
IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_35, analyzer);
indexWriter = new IndexWriter(directory, conf);
2.多线程往 IndexWriter中添加doc时报错(小概率事件)
异常信息:
java.lang.NullPointerException
at org.wltea.analyzer.Context.lockBuffer(Context.java:96)
at org.wltea.analyzer.seg.CJKSegmenter.nextLexeme(CJKSegmenter.java:162)
at org.wltea.analyzer.IKSegmentation.next(IKSegmentation.java:84)
at org.wltea.analyzer.lucene.IKTokenizer.incrementToken(IKTokenizer.java:51)
at org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:135)
at org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFieldProcessorPerThread.java:278)
at org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:766)
at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2066)
at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2040)
at com.ai.zj.inter.sys.rm.lucene.service.impl.LuceneIndexWriterSVImpl.geneDocuments(LuceneIndexWriterSVImpl.java:170)
at com.ai.zj.inter.sys.rm.lucene.service.impl.LuceneIndexWriterSVImpl._geneStdAddrLuceneInx(LuceneIndexWriterSVImpl.java:48)
at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.ai.appframe2.complex.service.proxy.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:110)
at com.sun.proxy.$Proxy12._geneStdAddrLuceneInx(Unknown Source)
at com.ai.zj.inter.sys.rm.lucene.task.sv.impl.NewResStdAddrLuceneInxGenerateTask.doTask(NewResStdAddrLuceneInxGenerateTask.java:138)
at com.asiainfo.appframe.ext.exeframe.task.TaskJob.execute(TaskJob.java:76)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
Original issue reported on code.google.com by jszh...@gmail.com on 12 Feb 2014 at 9:01
Original issue reported on code.google.com by
jszh...@gmail.com
on 12 Feb 2014 at 9:01