我正在尝试为Solr 4.6中的自定义过滤器构建一个jar。我在运行compile时遇到错误:
CustomFilter.java:19: error: package org.apache.lucene.analysis does not exist
import org.apache.lucene.analysis.TokenFilter;
^
CustomFilter.java:20: error: package org.apache.lucene.analysis does not exist
import org.apache.lucene.analysis.TokenStream;
^
CustomFilter.java:21: error: package org.apache.lucene.analysis.tokenattributes does not exist
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
^
CustomFilter.java:24: error: package org.apache.solr.util does not exist
import org.apache.solr.util.NumberUtils;
^
CustomFilter.java:43: error: cannot find symbol
public final class CustomFilter extends TokenFilter {
^
symbol: class TokenFilter
CustomFilter.java:46: error: cannot find symbol
private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
^
symbol: class CharTermAttribute
location: class CustomFilter
CustomFilter.java:47: error: cannot find symbol
private final PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
我需要一些关于将此自定义过滤器添加到我的架构的帮助。没有构建这个jar,如果我尝试在一个字段的模式中使用过滤器,我在我的solr管理员上面会出现以下错误:
org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] fieldType "textCustom": Plugin init failure for [schema.xml] analyzer/filter: Error instantiating class: 'org.apache.solr.analysis.Custom.CustomFilterFactory'. Schema file is /opt/solr5/collection3/schema.xml
对此有重复的问题,但没有正确的答案。因此,请不要在此基础上关闭此问题。
答案 0 :(得分:0)
看起来你正在尝试编译你的类文件而没有指向正确的依赖项,请确保你将类路径指向包含你的插件的目录,在这种情况下:org.apache.lucene.analysis.TokenFilter(同时检查你的其他依赖项)即:lucene-1.3.jar与java文件所在的目录相同
javac -cp:<directory> <file to compile>
javac -cp:. <file to compile> //period means classpath is same library to compile
还要确保您的自定义标记生成器库位于solr库中。检查schema.xml中的现有库,并将自定义solr过滤器库添加到同一目录中。