Defining as a "long" or "int" type throws an

系统 1640 0

solr启动时候,报如下异常:

[java] view plain copy

  1. SEVERE: org.apache.solr.common.SolrException 
  2.         at org.apache.solr.core.SolrCore.<init>(SolrCore.java:600) 
  3.         at org.apache.solr.core.CoreContainer.create(CoreContainer.java:480) 
  4.         at org.apache.solr.core.CoreContainer.load(CoreContainer.java:332) 
  5.         at org.apache.solr.core.CoreContainer.load(CoreContainer.java:216) 
  6.         at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:161) 
  7.         at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:96) 
  8.         at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295) 
  9.         at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422) 
  10.         at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115) 
  11.         at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838) 
  12.         at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) 
  13.         at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526) 
  14.         at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637) 
  15.         at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563) 
  16.         at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498) 
  17.         at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) 
  18.         at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) 
  19.         at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 
  20.         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) 
  21.         at org.apache.catalina.core.StandardHost.start(StandardHost.java:722) 
  22.         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) 
  23.         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) 
  24.         at org.apache.catalina.core.StandardService.start(StandardService.java:516) 
  25.         at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) 
  26.         at org.apache.catalina.startup.Catalina.start(Catalina.java:593) 
  27.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
  28.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
  29.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
  30.         at java.lang.reflect.Method.invoke(Method.java:597) 
  31.         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) 
  32.         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 
  33. Caused by: org.apache.solr.common.SolrException: Error initializing QueryElevationComponent. 
  34.         at org.apache.solr.handler.component.QueryElevationComponent.inform(QueryElevationComponent.java:202) 
  35.         at org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:527) 
  36.         at org.apache.solr.core.SolrCore.<init>(SolrCore.java:594) 
  37.         ... 32 more 
  38. Caused by: java.lang.NumberFormatException: For input string: "MA147LL/A"
  39.         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) 
  40.         at java.lang.Integer.parseInt(Integer.java:449) 
  41.         at java.lang.Integer.parseInt(Integer.java:499) 
  42.         at org.apache.solr.schema.TrieField.readableToIndexed(TrieField.java:291) 
  43.         at org.apache.solr.handler.component.QueryElevationComponent$ElevationObj.<init>(QueryElevationComponent.java:119) 
  44.         at org.apache.solr.handler.component.QueryElevationComponent.loadElevationMap(QueryElevationComponent.java:264) 
  45.         at org.apache.solr.handler.component.QueryElevationComponent.inform(QueryElevationComponent.java:186) 
  46.         ... 34 more 

我的solr版本是3.6.1。

通过查看异常堆栈 :Caused by: org.apache.solr.common.SolrException: Error initializing QueryElevationComponent.和Caused by: java.lang.NumberFormatException: For input string: "MA147LL/A"

问题定位在初始化QueryElevationComponent组件时失败。在solrconfig.xml文件中找到QueryElevationComponent的配置项:

[java] view plain copy

  1. <searchComponent name="elevator" class="solr.QueryElevationComponent"> 
  2. <!--  pick a fieldType to analyze queries  --> 
  3. <str name="queryFieldType">string</str> 
  4. <str name="config-file">elevate.xml</str> 
  5. </searchComponent> 
  6. <!-- 
  7. A request handler for demonstrating the elevator component  
  8. --> 
  9. <requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy"> 
  10. <lst name="defaults"> 
  11. <str name="echoParams">explicit</str> 
  12. <str name="df">text</str> 
  13. </lst> 
  14. <arr name="last-components"> 
  15. <str>elevator</str> 
  16. </arr> 
  17. </requestHandler> 

从配置文件得知在初始化QueryElevationComponent的时候会去加载conf目录下的elevate.xml文件,所以打开elevate.xml文件看看:

[java] view plain copy

  1. <elevate> 
  2. <query text="foo bar"> 
  3.   <doc id="1" /> 
  4.   <doc id="2" /> 
  5.   <doc id="3" /> 
  6. </query> 
  7. <query text="ipod"> 
  8.    <doc id="MA147LL/A" />  <!-- put the actual ipod at the top --> 
  9.    <doc id="IW-02" exclude="true" /> <!-- exclude this cable --> 
  10. </query> 
  11. </elevate> 

你会发现有一个id="MA147LL/A"和id="IW-02"的配置项,问题就在于id的值为"MA147LL/A"和IW-02,它是string类型,当我们把所<uniqueKey> id 定义为long或int等number类型时,自然会报以上异常。

这是一个solr的bug: https://issues.apache.org/jira/browse/SOLR-2997

有两种解决方案:

(一)将id="MA147LL/A" 改为id="1",将id="IW-02"改为id="2",将其值设为整形。

(一)在solrconfig.xml文件中注释掉以下代码:(QueryElevationComponent组件对于初学者一般上不用,所以可以先注释掉)

[java] view plain copy

  1. <searchComponent name="elevator" class="solr.QueryElevationComponent"> 
  2. <!--  pick a fieldType to analyze queries  --> 
  3. <str name="queryFieldType">string</str> 
  4. <str name="config-file">elevate.xml</str> 
  5. </searchComponent> 
  6. <!-- 
  7. A request handler for demonstrating the elevator component  
  8. --> 
  9. <requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy"> 
  10. <lst name="defaults"> 
  11. <str name="echoParams">explicit</str> 
  12. <str name="df">text</str> 
  13. </lst> 
  14. <arr name="last-components"> 
  15. <str>elevator</str> 
  16. </arr> 
  17. </requestHandler> 

PS: QueryElevationComponent组件用于solr实现竞价排名,接下来会写一篇关于solr竞价排名的文章。

Defining as a "long" or "int" type throws an error on startup


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论