2016-01-20 47 views
0

我想更新从Solr的4我的Solr基于应用到Solr 5.3.1加入我自己的类来SOLR 5.3.1

我才发现,因为Solr的5.2不再可能运行Solr的作为Web应用程序。 因此,现在我需要将我的源代码放入Solr中,而不是将项目打包为WAR,并将其与单独的Jetty一起运行。 但我该怎么做?

我想我的打包项目作为一个JAR文件,并把它夹在/solr-5.3.1/contrib/mySearchApplication/lib/mysearch.jar我和solrconfig.xml中添加<lib dir="${solr.install.dir:../../../..}/contrib/mySearchApplication/lib" regex=".*\.jar" />这条道路,但是当我尝试运行的Solr仍然无法找到我的职业,例如我的自定义令牌过滤器

那么如何添加我的java类到solr?

我收到此错误信息:

ERROR (coreLoadExecutor-6-thread-1) [ ] o.a.s.c.CoreContainer Error creating core [myCollection]: Could not load conf for core myCollection: Plugin init failure for [schema.xml] fieldType "text_en": Plugin init failure for [schema.xml] analyzer/filter: Error loading class 'com.mySearchApplication.lucene.analysis.pattern.SplitOnPatternFilterFactory'. Schema file is /var/tmp/solr/myCollection/conf/schema.xml org.apache.solr.common.SolrException: Could not load conf for core myCollection: Plugin init failure for [schema.xml] fieldType "text_en": Plugin init failure for [schema.xml] analyzer/filter: Error loading class 'com.mySearchApplication.lucene.analysis.pattern.SplitOnPatternFilterFactory'. Schema file is /var/tmp/solr/myCollection/conf/schema.xml at org.apache.solr.core.ConfigSetService.getConfig(ConfigSetService.java:80) at org.apache.solr.core.CoreContainer.create(CoreContainer.java:721) at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:443) at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:434) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor$1.run(ExecutorUtil.java:210) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] fieldType "text_en": Plugin init failure for [schema.xml] analyzer/filter: Error loading class 'com.mySearchApplication.lucene.analysis.pattern.SplitOnPatternFilterFactory'. Schema file is /var/tmp/solr/myCollection/conf/schema.xml at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:596) at org.apache.solr.schema.IndexSchema.<init>(IndexSchema.java:175) at org.apache.solr.schema.IndexSchemaFactory.create(IndexSchemaFactory.java:55) at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69) at org.apache.solr.core.ConfigSetService.createIndexSchema(ConfigSetService.java:104) at org.apache.solr.core.ConfigSetService.getConfig(ConfigSetService.java:75) ... 8 more

+0

可能你的路径是错误的。将你的lib文件夹复制到与'solrconfig.xml'相同的父文件夹中并使用'dir =“lib”':https://cwiki.apache.org/confluence/display/solr/Lib+Directives+in+SolrConfig –

+0

谢谢为答案。我尝试了,但仍然得到: 'org.apache.solr.common.SolrException:org.apache.solr.common.SolrException:无法为core myCollection加载conf:[schema.xml]的插件初始化失败fieldType“text_en “:[schema.xml]分析器/筛选器的插件初始化失败:加载类”com.mySearchApplication.lucene.analysis.pattern.SplitOnPatternFilterFactory“时出错。架构文件是/ var/tmp/solr/myCollection/conf/schema.xml' – MrLang

+0

请将现有过滤器复制并重命名为jar文件,然后尝试从solr访问它。可能你的“SplitOnPatternFilterFactory”类有一个静态构造函数的问题? http://stackoverflow.com/questions/6352215/java-why-java-lang-noclassdeffounderror-caused-by-static-field-initializ-failur –

回答

0

您可以添加sharedLib参数到solr.xml文件。

此参数指定共享库目录的路径, 将在所有核心间共享。此目录中的任何JAR文件将被添加到Solr插件的搜索路径中。此路径相对于顶层容器的Solr Home的 。

这是我做的。

<?xml version='1.0' encoding='UTF-8'?> 
<solr> 
     <str name='sharedLib'>/opt/shared-lib</str> 

     <solrcloud> 
      <str name="host">${host:}</str> 
      <int name="hostPort">${hostPort:8080}</int> 
      <str name="hostContext">${hostContext:solr}</str> 
      <int name="zkClientTimeout">${zkClientTimeout:15000}</int> 
      <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool> 
     </solrcloud> 

     <shardHandlerFactory name="shardHandlerFactory" 
      class="HttpShardHandlerFactory"> 
      <int name="socketTimeout">${socketTimeout:0}</int> 
      <int name="connTimeout">${connTimeout:0}</int> 
     </shardHandlerFactory> 

</solr> 
+0

感谢您的答案,但是当我尝试这个我得到: 'java .lang.NullPointerException \t在org.apache.solr.servlet.SolrDispatchFilter.authenticateRequest(SolrDispatchFilter.java:241) \t在org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:186) \t在有机.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:179) \t在org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1652) \t在org.eclipse.jetty.servlet .ServletHandler.doHandle(ServletHandler.java:585)' – MrLang

+0

修复语法错误后,我仍然得到: 'org.apache.solr.common.SolrException:org.apache.solr.common.SolrException:无法为core myCollection加载conf:[schema.xml]的插件初始化失败fieldType“text_en”:[schema.xml]分析器/过滤器的插件初始化失败:加载类'com.mySearchApplication.lucene.analysis.pattern.SplitOnPatternFilterFactory'时出错。架构文件是/ var/tmp/solr/myCollection/conf/schema.xml' 任何想法我可以尝试吗? – MrLang

+0

在指定库的位置时尝试使用绝对路径。并确保所有的依赖性得到满足。 – freedev