在使用lucene3与IKAnalyzer集成的时候可能会出现以下错误:
Exception in thread "main" java.lang.AbstractMethodError: org.apache.lucene.analysis.TokenStream.incrementToken()Z
at org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:137)
at org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFieldProcessorPerThread.java:246)
at org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:774)
at org.apache.lucene.index.DocumentsWriter.addDocument(DocumentsWriter.java:752)
at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1932)
at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1906)
原因是:IKAnalyzer以前发布的jar与lucene3不兼容。兼容版本如附件图
- 大小: 74.6 KB
分享到:
相关推荐
Exception in thread "main" java.lang.AbstractMethodError: org.apache.lucene.analysis.TokenStream.incrementToken()Z 换用svn里源码版正常 http://paoding.googlecode.com/svn/trunk/paoding-analysis/
Exception in thread "main" java.lang.AbstractMethodError: org.apache.lucene.analysis.TokenStream.incrementToken()Z at org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField....
解决Exception in thread "main" java.lang.VerifyError: class org.wltea.analyzer.lucene.IKAnalyzer overrides final method tokenStream.(Ljava/lang/String;Ljava/io/Reader;)Lorg/apache/lucene/analysis/...
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexReader; import org.apache....
- `org.apache.lucene.analysis`: 提供语言分析器,负责文本的预处理,如分词。对于中文,通常需要使用特定的分词器,如IK Analyzer或HanLP。 - `org.apache.lucene.document`: 定义了文档的结构,文档由一系列...
import org.apache.lucene.analysis.TokenStream; import org.mira.lucene.analysis.MIK_CAnalyzer; public class TestLucene { /** * @param args */ public static void main(String[] args) { String...
while (tokenStream.incrementToken()) { CharTermAttribute charTermAttribute = tokenStream.getAttribute(CharTermAttribute.class); System.out.println(new String(charTermAttribute.buffer())); } } } `...
- **Analyzer API**: 如`org.apache.lucene.analysis.Analyzer`,提供了创建自定义分析器的方法,如`createComponents(String fieldName, Reader reader)`,用于创建TokenStream。 - **IndexWriter API**: 如`org....
while (tokenStream.incrementToken()) { System.out.println(termAttr.toString()); } tokenStream.end(); tokenStream.close(); } catch (Exception e) { e.printStackTrace(); } } } ``` 上述代码会输出...
<filter class="org.apache.lucene.analysis.miscellaneous.SetKeywordMarkerFilter" factory="org.apache.solr.analysis.TokenizerChainFactory" protected="protwords.txt"/> <tokenizer class="com.iscas....
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; public class MmsegAnalyzer extends Analyzer { @Override protected TokenStreamComponents createComponents...
在Java环境中,Apache Lucene是一个广泛使用的全文搜索引擎库,它提供了丰富的文本处理工具,包括分词功能。 标题提到的"MMAnalyzer 分词jar包"是基于Lucene的一个中文分词组件,名为Jeasy Analysis,具体版本为...
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; public class Mmseg4jAnalyzer extends Analyzer { @Override protected TokenStreamComponents create...
import org.apache.lucene.analysis.TokenStream; // 创建分词器实例 Analyzer analyzer = new Analyzer(); // 获取TokenStream对象,处理文本 TokenStream tokenStream = analyzer.tokenStream("content", "这是...
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; IKAnalyzer analyzer = new IKAnalyzer(); String text = "基于IK的中文分词"; ...
while (tokenStream.incrementToken()) { String word = termAttr.term(); if (!wordCount.containsKey(word)) { wordCount.put(word, 1); } else { wordCount.put(word, wordCount.get(word) + 1); } } } ...
在Lucene5中,我们可以继承`org.apache.lucene.analysis.Analyzer`类来创建自定义分词器。这通常包括定义一个定制的`TokenStream`类,比如`Tokenizer`和`TokenFilter`,以实现特定的分词逻辑。对于同义词处理,我们...
while (tokenStream.incrementToken()) { System.out.println(tokenStream.getAttribute(CharTermAttribute.class).toString()); } tokenStream.close(); analyzer.close(); } } ``` 在这个例子中,我们创建...
Lucene.net是Apache Lucene项目的一个.NET版本,它是一个高性能、全文本搜索库,提供了强大的文本分析、索引和搜索功能。Lucene.net 2.9是其一个稳定版本,支持多种.NET框架,可以用于构建各种搜索应用程序。它提供...