我是SOLR的新手。使用DataImporter将MySQL记录带入索引。导入有效,但创建了0个文档。我看到以下错误:
org.apache.solr.common.SolrException:文档缺少必需的uniqueKey字段:id
我的data-config.xml如下所示:
<dataConfig>
<dataSource type="JdbcDataSource" driver="org.gjt.mm.mysql.Driver" url="jdbc:mysql://localhost/gartner" user="" password="" batchSize="-1" />
<document name="inquiries">
<entity name="inquiry_data" query="SELECT * FROM research_srv_req">
<field column="reference_id" name="reference_id" />
<field column="type" name="type" />
<field column="sub_type" name="sub_type" />
<field column="subject" name="inquiry_subject" />
<field column="advice" name="advice" />
<field column="client_question" name="client_question" />
<field column="decision_stage_desc" name="decision_stage_desc" />
<field column="acct_name" name="acct_name" />
<field column="acct_sic_type" name="acct_sic_type" />
<field column="acct_sic_sub_type" name="acct_sic_sub_type" />
<field column="enterprise_sic_type" name="enterprise_sic_type" />
<field column="enterprise_sic_sub_type" name="enterprise_sic_sub_type" />
<field column="client_job_title" name="client_job_title" />
</entity>
</document>
我在schema.xml文件中添加了以下内容:
<field name="reference_id" type="int" indexed="true" stored="true" required="true" multiValued="false" />
<field name="type" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="sub_type" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="inquiry_subject" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="advice" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="client_question" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="decision_stage" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="acct_name" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="acct_sic_type" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="acct_sic_sub_type" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="enterprise_sic_type" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="enterprise_sic_sub_type" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="client_job_title" type="string" indexed="true" stored="true" required="true" multiValued="false" />
原始schema.xml也有以下行:
<uniqueKey>id</uniqueKey>
我尝试将id更改为reference_id,这是我数据库中的唯一列,但是SOLR无法使用以下堆栈转储加载:
消息{msg = SolrCore&#39;集合1&#39;由于init失败而无法使用:初始化QueryElevationComponent时出错。,trace = org.apache.solr.common.SolrException:SolrCore&#39; collection1&#39;由于init失败而无法使用:初始化QueryElevationComponent时出错。在org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:860)在org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:251)在org.apache.solr.servlet.SolrDispatchFilter.doFilter (SolrDispatchFilter.java:158)在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)在org.apache。 catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java: 127)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)atg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)org.apache.catalina.connector.CoyoteAdapter .service(CoyoteAdapter.java:298)org.apache.coyote.http11.Http11Processor.process(Http11Processor。 java:859)org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:588)at org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:489)at java .lang.Thread.run(Unknown Source)由以下原因引起:org.apache.solr.common.SolrException:初始化QueryElevationComponent时出错。 org.apache.solr.core.SolrCore。(SolrCore.java:835)org.apache.solr.core.SolrCore。(SolrCore.java:629)org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer) .java:622)org.apache.solr.core.CoreContainer.create(CoreContainer.java:657)org.apache.solr.core.CoreContainer $ 1.call(CoreContainer.java:364)org.apache.solr .core.CoreContainer $ 1.call(CoreContainer.java:356)at java.util.concurrent.FutureTask $ Sync.innerRun(Unknown Source)at java.util.concurrent.FutureTask.run(Unknown Source)at java.util.concurrent .Executors $ RunnableAdapter.call(Unknown Source)at java.util.concurrent.FutureTask $ Sync.innerRun(Unknown Source)at java.util.concurrent.FutureTask.run(Unknown Source)at java.util.concurrent.ThreadPoolExecutor $ Worker java.util.concurrent.ThreadPoolExecutor中的.runTask(未知来源)$ Worker.run(未知来源)... 1更多引起:org.apache.solr.common.SolrException:初始化QueryElevationComponent时出错。位于org.apache.solrCore.SolrCore上org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:601)的org.apache.solr.handler.component.QueryElevationComponent.inform(QueryElevationComponent.java:240) 。(SolrCore.java:830)... 13更多引起:java.lang.NumberFormatException:对于输入字符串:&#34; MA147LL / A&#34; at java.lang.NumberFormatException.forInputString(Unknown Source)at java.lang.Integer.parseInt(Unknown Source)at java.lang.Integer.parseInt(Unknown Source)at org.apache.solr.schema.TrieField.readableToIndexed(TrieField) .java:387)atg.apache.solr.schema.TrieField.readableToIndexed(TrieField.java:378)atg.apache.solr.handler.component.QueryElevationComponent $ ElevationObj。(QueryElevationComponent.java:136)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} 说明服务器遇到内部错误({msg = SolrCore&#39;集合1&#39;因初始化失败而无效:初始化QueryElevationComponent时出错。,trace = org.apache.solr.common.SolrException:SolrCore&#39;由于init失败,collection1&#39;不可用:在org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter)的org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:860)初始化QueryElevationComponent时出错。的java:251)在org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:158)在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)在org.apache.catalina.core .ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)在org.apache.catalina.core.StandardHostValve.invoke(StandardHost Valve.java:127)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)atg.apache.catalina .connector.CoyoteAdapter.service(CoyoteAdapter.java:298)在org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)在org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java :588)atg.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:489)at java.lang.Thread.run(Unknown Source)引起:org.apache.solr.common.SolrException :初始化QueryElevationComponent时出错。 org.apache.solr.core.SolrCore。(SolrCore.java:835)org.apache.solr.core.SolrCore。(SolrCore.java:629)org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer) .java:622)org.apache.solr.core.CoreContainer.create(CoreContainer.java:657)org.apache.solr.core.CoreContainer $ 1.call(CoreContainer.java:364)org.apache.solr .core.CoreContainer $ 1.call(CoreContainer.java:356)at java.util.concurrent.FutureTask $ Sync.innerRun(Unknown Source)at java.util.concurrent.FutureTask.run(Unknown Source)at java.util.concurrent .Executors $ RunnableAdapter.call(Unknown Source)at java.util.concurrent.FutureTask $ Sync.innerRun(Unknown Source)at java.util.concurrent.FutureTask.run(Unknown Source)at java.util.concurrent.ThreadPoolExecutor $ Worker java.util.concurrent.ThreadPoolExecutor中的.runTask(未知来源)$ Worker.run(未知来源)... 1更多引起:org.apache.solr.common.SolrException:初始化QueryElevationComponent时出错。位于org.apache.solrCore.SolrCore上org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:601)的org.apache.solr.handler.component.QueryElevationComponent.inform(QueryElevationComponent.java:240) 。(SolrCore.java:830)... 13更多引起:java.lang.NumberFormatException:对于输入字符串:&#34; MA147LL / A&#34; at java.lang.NumberFormatException.forInputString(Unknown Source)at java.lang.Integer.parseInt(Unknown Source)at java.lang.Integer.parseInt(Unknown Source)at org.apache.solr.schema.TrieField.readableToIndexed(TrieField) .java:387)atg.apache.solr.schema.TrieField.readableToIndexed(TrieField.java:378)atg.apache.solr.handler.component.QueryElevationComponent $ ElevationObj。(QueryElevationComponent.java:136)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})that that阻止它履行这一要求。
我做错了什么?
答案 0 :(得分:3)
UniqueKey需要是一个字符串。你试图把它变成一个int。尝试将 reference_id 的类型更改为字符串并重新编制索引。
答案 1 :(得分:1)
在进入schema.xml之前,请删除字段
中的required="true"
属性
你有两个解决方案
1)在您的data-config.xml中,将任何字段名称作为id,在表中为唯一。 我想你的表中reference_id是唯一的
<field column="reference_id" name="reference_id" />
将该字段的名称属性更改为id,如下所示
<field column="reference_id" name="id" />
现在转到schema.xml并搜索此关键字 field name =“id”
如果它存在然后检查/添加属性required =“true”(这意味着你的强制id是必需的),也
删除其他字段的 required=true
。
如果关键字字段名称=“id”不存在 然后创建一个新的,如下面
<field name="id" type="string" indexed="true" stored="true" required="true"></field>
在这里,你重新开始并运行
2)找到keyWord field name =“id”,如果它存在,则删除该字段本身, 同时删除 id 标记
在这里,你重新开始并运行
希望任何一种方法都有帮助