2016-01-20 45 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