IKAnalyzer3.2.0 Stable版使用自定义词典出现数组下标越界异常

使用环境:

Solr1.4

Lucene2.9.1 或 Lucene2.9.2 或 Lucene2.9.3

出错过程:

根据IKAnalyzer3.X官方手册,配置自定义词典,在启动时报错如下,把自定义词典移除,异常不再就不出现。

2010-7-22 9:51:15 org.apache.solr.common.SolrException log
严重: java.lang.ExceptionInInitializerError
        at org.wltea.analyzer.seg.ChineseSegmenter.<init>(ChineseSegmenter.java:37)
        at org.wltea.analyzer.cfg.Configuration.loadSegmenter(Configuration.java:114)
        at org.wltea.analyzer.IKSegmentation.<init>(IKSegmentation.java:54)
        at org.wltea.analyzer.lucene.IKTokenizer.<init>(IKTokenizer.java:44)
        at org.wltea.analyzer.solr.IKTokenizerFactory.create(IKTokenizerFactory.java:45)
        at org.apache.solr.analysis.TokenizerChain.getStream(TokenizerChain.java:69)
        at org.apache.solr.analysis.SolrAnalyzer.reusableTokenStream(SolrAnalyzer.java:74)
        at org.apache.solr.schema.IndexSchema$SolrIndexAnalyzer.reusableTokenStream(IndexSchema.java:364)
        at org.apache.lucene.queryParser.QueryParser.getFieldQuery(QueryParser.java:567)
        at org.apache.solr.search.SolrQueryParser.getFieldQuery(SolrQueryParser.java:153)
        at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1449)
        at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1337)
        at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1265)
        at org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1254)
        at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:200)
        at org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:78)
        at org.apache.solr.search.QParser.getQuery(QParser.java:131)
        at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:89)
        at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:174)
        at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131)
        at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316)
        at org.apache.solr.core.QuerySenderListener.newSearcher(QuerySenderListener.java:52)
        at org.apache.solr.core.SolrCore$3.call(SolrCore.java:1146)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
        at org.wltea.analyzer.dic.DictSegment.fillSegment(DictSegment.java:139)
        at org.wltea.analyzer.dic.DictSegment.fillSegment(DictSegment.java:128)
        at org.wltea.analyzer.dic.Dictionary.loadMainDict(Dictionary.java:134)
        at org.wltea.analyzer.dic.Dictionary.<init>(Dictionary.java:71)
        at org.wltea.analyzer.dic.Dictionary.<clinit>(Dictionary.java:41)
        ... 28 more

从官网下载源代码,重新编译然后打包,替换原来的包,启动后异常不再出现。

==============================

2010.07.26

今天问题再次出现,用Lucene2.9.3替换Lucene2.9.1 或Lucene2.9.2后,问题暂时解决