0

现在我的 schma.xml 配置是:

<fieldType name="text_exact_fuzzy" class="solr.TextField" omitNorms="false">
     <analyzer type="index">
          <tokenizer class="solr.StandardTokenizerFactory"/>
          <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="7"/>
          <filter class="solr.LowerCaseFilterFactory"/>
     </analyzer>
     <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="7"/>
        <filter class="solr.LowerCaseFilterFactory"/>      
     </analyzer>
</fieldType>

但是现在我在向 solr 添加数据时遇到了这样的问题,我用 solr.StandardTokenizerFactory 定义了 fieldType 的分析器,没有任何问题,但是当使用 solr.EdgeNGramFilterFactory 的分析器可以得到这样的错误时。我已经导入了 jar,例如 lucene-analyzers-common-4.5.0.jar、lucene-analyzers-3.5.0.jar 等。我认为 lucene-analyzers-common-4.5.0.jar 包含了 EdgeNGramFilterFactory 类。

java.lang.NoSuchMethodError: org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter.<init>(Lorg/apache/lucene/util/Version;Lorg/apache/lucene/analysis/TokenStream;Ljava/lang/String;II)V
        at org.apache.lucene.analysis.ngram.EdgeNGramFilterFactory.create(EdgeNGramFilterFactory.java:52)
        at org.apache.lucene.analysis.ngram.EdgeNGramFilterFactory.create(EdgeNGramFilterFactory.java:34)
        at org.apache.solr.analysis.TokenizerChain.createComponents(TokenizerChain.java:67)
        at org.apache.lucene.analysis.AnalyzerWrapper.createComponents(AnalyzerWrapper.java:102)
        at org.apache.lucene.analysis.Analyzer.tokenStream(Analyzer.java:180)
        at org.apache.lucene.document.Field.tokenStream(Field.java:552)
        at org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:95)
        at org.apache.lucene.index.DocFieldProcessor.processDocument(DocFieldProcessor.java:248)
        at org.apache.lucene.index.DocumentsWriterPerThread.updateDocument(DocumentsWriterPerThread.java:254)
        at org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:446)
        at org.apache.lucene.index.IndexWriter.updateDocument(IndexWriter.java:1521)
        at org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:217)
        at org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:69)
        at org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:51)
        at org.apache.solr.update.processor.DistributedUpdateProcessor.doLocalAdd(DistributedUpdateProcessor.java:556)
        at org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:692)
        at org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:435)
        at org.apache.solr.update.processor.LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:100)
        at org.apache.solr.handler.loader.XMLLoader.processUpdate(XMLLoader.java:247)
        at org.apache.solr.handler.loader.XMLLoader.load(XMLLoader.java:174)
        at org.apache.solr.handler.UpdateRequestHandler$1.load(UpdateRequestHandler.java:92)
        at org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(ContentStreamHandlerBase.java:74)
        at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
        at org.apache.solr.core.SolrCore.execute(SolrCore.java:1859)
        at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:150)
        at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:117)
        at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:68)
        at org.apache.solr.client.solrj.SolrServer.addBeans(SolrServer.java:93)
        at org.apache.solr.client.solrj.SolrServer.addBeans(SolrServer.java:77)

Please help me, thanks a lot!
4

1 回答 1

1

你需要添加 apache-lucene-analyzers.jar ,你可以从这里下载

于 2013-11-13T08:04:18.267 回答