我想将基于solr的应用程序从Solr 4更新为Solr 5.3.1
我刚刚发现,因为Solr 5.2不再可能将Solr作为WebApp运行。 因此,不是将项目(使用solr作为Maven依赖项)打包为WAR并使用单独的Jetty运行它,现在我需要将我的源代码放入Solr。 但我怎么能这样做?
我尝试将我的项目打包为JAR并将其放在文件夹/solr-5.3.1/contrib/mySearchApplication/lib/mysearch.jar
中,并在solrconfig.xml <lib dir="${solr.install.dir:../../../..}/contrib/mySearchApplication/lib" regex=".*\.jar" />
中添加了此路径,但是当我尝试运行Solr时,它仍然可以&#39;找到我的课程,例如我自定义的令牌过滤器。
那么如何将我的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 :(得分:1)
您可以将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>
答案 1 :(得分:0)
在Windows中,solr.xml可能看起来像这样:
<solr>
<str name='sharedLib'>F:\solr_deployment\solr-7.6.0\contrib\analysis-extras\lucene-libs</str>
<solrcloud>
<str name="host">${host:}</str>
<int name="hostPort">${jetty.port:8983}</int>
<str name="hostContext">${hostContext:solr}</str>
<bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
<int name="zkClientTimeout">${zkClientTimeout:30000}</int>
<int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:600000}</int>
<int name="distribUpdateConnTimeout">${distribUpdateConnTimeout:60000}</int>
<str name="zkCredentialsProvider">${zkCredentialsProvider:org.apache.solr.common.cloud.DefaultZkCredentialsProvider}</str>
<str name="zkACLProvider">${zkACLProvider:org.apache.solr.common.cloud.DefaultZkACLProvider}</str>
</solrcloud>
<shardHandlerFactory name="shardHandlerFactory"
class="HttpShardHandlerFactory">
<int name="socketTimeout">${socketTimeout:600000}</int>
<int name="connTimeout">${connTimeout:60000}</int>
</shardHandlerFactory>
</solr>
或者,可以在solrconfig.xml文件中使用它:
<config>
<luceneMatchVersion>7.6.0</luceneMatchVersion>
<lib dir="${solr.install.dir:../../../..}/contrib/extraction/lib" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-cell-\d.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/contrib/clustering/lib/" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-clustering-\d.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/contrib/langid/lib/" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-langid-\d.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/contrib/velocity/lib" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-velocity-\d.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lucene-libs" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-analysis-\d.*\.jar" />
...
</config>