Solr异常:重新索引时出现未定义字段错误

3
希望你能帮助我。我正在维护一个应用程序,遇到了一个问题。该应用程序使用SOLR进行索引,并且应该从数据库中填充两个核心的数据。
当重新索引时,我不断收到以下错误信息:
Aug 22, 2013 10:09:49 AM org.apache.solr.common.SolrException log

SEVERE: org.apache.solr.common.SolrException: undefined field: "editor_id"

    at org.apache.solr.schema.IndexSchema.getField(IndexSchema.java:965)

[... Stack trace ...]

    at java.lang.Thread.run(Thread.java:679)

这个核心的schema.xml:

<solrQueryParser defaultOperator="AND" />

<fields>

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

    <field name="division_id" type="long" indexed="true" stored="false" multiValued="false"/>
    <field name="division" type="text_nl" indexed="true" stored="false" multiValued="false"/>

    <field name="subdivision_id" type="long" indexed="true" stored="false" multiValued="false"/>
    <field name="subdivision" type="text_nl" indexed="true" stored="false" multiValued="false"/>

    <field name="editor_id" type="long" indexed="true" stored="false" multiValued="false"/>
    <field name="editor" type="text_nl" indexed="true" stored="false" multiValued="false"/>

    <field name="status" type="text_nl" indexed="true" stored="false" multiValued="false"/>
    <field name="status_id" type="long" indexed="true" stored="false" multiValued="false"/>

    <field name="lines" type="text_nl" indexed="true" stored="false" multiValued="true"/>

    <field name="text" type="text_nl" indexed="true" stored="false" multiValued="true"/>

    <field name="_version_" type="long" indexed="true" stored="true"/>

    <field name="suggest_nl" type="text_nl_suggest" indexed="true" stored="true" multiValued="true"/>
    <copyField source="*" dest="suggest_nl"/>

</fields>

<uniqueKey>id</uniqueKey>

如您所见,编辑器ID在模式中存在。在我们从数据表获取数据时,表名已重命名为editor_user_id。当我将schema.xml规则从editor_id改为editor_user_id时,它仍会返回上述错误,好像schema.xml是无关紧要的。
我是否忽略了更新模式以匹配数据库表的方法?
如何消除此错误的任何建议都将不胜感激,因为当涉及SOLR/LUCENE/TOMCAT设置时,我有点新手。
谢谢。
编辑:
以下是完整的堆栈跟踪:
2013年8月22日11:47:52 org.apache.solr.common.SolrException日志 严重错误:org.apache.solr.common.SolrException:未定义字段:“editor_id” 在org.apache.solr.schema.IndexSchema.getField(IndexSchema.java:965)处 在org.apache.solr.schema.IndexSchema.getCopyFieldsList(IndexSchema.java:1077)处 在org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:274)处 在org.apache.solr.update.AddUpdateCommand.getLuceneDocument(AddUpdateCommand.java:73)处 在org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:201)处 在org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:69)处 在org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:51)处 在org.apache.solr.update.processor.DistributedUpdateProcessor.doLocalAdd(DistributedUpdateProcessor.java:455)处 在org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:591)处 在org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:350)处 在org.apache.solr.update.processor.LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:100)处 在org.apache.solr.handler.loader.XMLLoader.processUpdate(XMLLoader.java:246)处 在org.apache.solr.handler.loader.XMLLoader.load(XMLLoader.java:173)处 在org.apache.solr.handler.UpdateRequestHandler$1.load(UpdateRequestHandler.java:92)处 在org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(ContentStreamHandlerBase.java:74)处 在org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)处 在org.apache.solr.core.SolrCore.execute(SolrCore.java:1816)处 在org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:448)处 在org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:269)处 在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)处 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)处 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)处 在org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)处 在org.apache.coyote.http11.Http11Protocol$ Http11ConnectionHandler.process(Http11Protocol.java:602)处 在org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:489)处 在java.lang.Thread.run(Thread.java:679)处

请粘贴整个堆栈跟踪吗 :) 当您尝试运行服务器时,是否会出现此错误? - Allan Macmillan
编辑器中的堆栈跟踪。在重新索引“items”核心之前,我没有遇到过这个错误。正如您所看到的模式,它将editor_id定义为long类型。当我将其更改为例如editor_user_id时,堆栈跟踪仍然保持不变。 - sn0r
你使用什么过程将数据加载到Solr索引中?是DataImportHandler、自定义代码等。你能展示该过程的相关部分吗?因为似乎需要更改以适应数据库字段名称的变化。 - Paige Cook
你能找出根本原因吗? - Sid
2个回答

1

您需要重新启动Solr服务器(Tomcat / jetty),以反映Solr配置文件(schema.xml,solrconfig.xml)中的任何更改。


到目前为止,我每次更改都重新启动了.. 没有帮助。 - sn0r

1

您可能在不同的文件夹中拥有多个schema.xml文件。

实际使用的文件应该在solrconfig.xml或solr.xml中以多种不同的方式指定。如果您拥有更多的schema.xml副本,请查看其他文件以检查是否有对其的引用。

还要检查是否有主从环境,如果是这样,您可能需要手动将文件复制到主服务器和从服务器,并/或在solrconfig.xml中指定在复制时需要复制它。


您还可以在管理界面中查看活动模式,例如http://localhost:8090/solr/#/webshop/schema。 - Cees Timmerman

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接