在solr中将唯一键声明为int会导致错误

时间:2013-10-17 07:46:33

标签: solr

声明

<field name="id" type="int" indexed="true" stored="true" required="true" 
 multiValued="false" />
schema.xml中的

会导致以下错误。

 HTTP Status 500 - {msg=SolrCore 'collection1' is not available due to init failure:     Error initializing QueryElevationComponent.,trace=org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: Error initializing QueryElevationComponent. at 
    org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:860) at 
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:251) at 
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:158) at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at
 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at
 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at
 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at 
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at 
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at 
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at 
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at 
java.lang.Thread.run(Thread.java:619) Caused by: org.apache.solr.common.SolrException: Error initializing QueryElevationComponent. at 
org.apache.solr.core.SolrCore.<init>(SolrCore.java:835) at 
org.apache.solr.core.SolrCore.<init>(SolrCore.java:629) at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:622) at 
org.apache.solr.core.CoreContainer.create(CoreContainer.java:657) at 
org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:364) at 
org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:356) at 
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at 
java.util.concurrent.FutureTask.run(FutureTask.java:138) at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at 
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at 
java.util.concurrent.FutureTask.run(FutureTask.java:138) 
... 3 more Caused by: org.apache.solr.common.SolrException: Error initializing QueryElevationComponent. at 
org.apache.solr.handler.component.QueryElevationComponent.inform(QueryElevationComponent.java:240) at 
org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:601) at 
org.apache.solr.core.SolrCore.<init>(SolrCore.java:830) 
... 13 more Caused by: java.lang.NumberFormatException: For input string: "MA147LL/A" at
 java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at 
java.lang.Integer.parseInt(Integer.java:449) at java.lang.Integer.parseInt(Integer.java:499) at 
org.apache.solr.schema.TrieField.readableToIndexed(TrieField.java:387) at 
org.apache.solr.schema.TrieField.readableToIndexed(TrieField.java:378) at 
org.apache.solr.handler.component.QueryElevationComponent$ElevationObj.<init>(QueryElevationComponent.java:136) at 
org.apache.solr.handler.component.QueryElevationComponent.loadElevationMap(QueryElevationComponent.java:309) at 
org.apache.solr.handler.component.QueryElevationComponent.inform(QueryElevationComponent.java:223) ... 15 more ,code=500}

任何人都可以告诉我为什么会这样吗?

2 个答案:

答案 0 :(得分:26)

转到elevate.xml @ SOLR_HOME \ example \ example-DIH \ solr \ solr \ conf

以这种方式修改

<query text="ipod">
<!--   <doc id="MA147LL/A" />   put the actual ipod at the top 
   <doc id="IW-02" exclude="true" /> exclude this cable -->
 </query>

所以,你实际上注释掉了这两行导致你的异常

<doc id="MA147LL/A" />   put the actual ipod at the top 
<doc id="IW-02" exclude="true" /> exclude this cable

我希望它能解决你的问题。

答案 1 :(得分:1)

您将id定义为int,并从错误消息中尝试将此内容MA147LL/A添加到其中(NumberFormatException:对于输入字符串:“MA147LL / A”at)。 。

使用schema.xml中的以下行

<field name="id" type="string" indexed="true" stored="true" 
 required="true" multiValued="false" />

你应该没事