SolrException:Document [null]缺少必填字段:id

时间:2011-06-23 21:08:03

标签: apache tomcat apache2 solr

我更改了schema.xml文件并添加了几个字段,就像这样

<field name="url" type="string" indexed="true" stored="true" />
   <field name="content_type" type="text" indexed="true" stored="true" />
   <field name="title" type="text" indexed="true" stored="true" />
   <field name="keywords" type="text" indexed="true" stored="true" multiValued="true" />
   <field name="text" type="text" indexed="true" stored="true" />
   <field name="timestamp" type="text" indexed="true" stored="true" />
   <field name="public" type="text" indexed="true" stored="true" multiValued="true" />
   <field name="groups" type="text" indexed="true" stored="true" multiValued="true" />
   <field name="sitename" type="text" indexed="true" stored="true" />
   <field name="context" type="text" indexed="true" stored="true" />
   <field name="modified_date" type="text" indexed="true" stored="true" />

因此,对应于这些字段,我创建了一个xml文件,并在其中添加了一些虚拟数据。

    <add><doc>
  <field name="url">http://www.host.com/</field>
  <field name="content_type">text/html</field>
  <field name="title">Testing Data</field>
  <field name="keywords">software</field>
  <field name="keywords">software_cycle</field>
  <field name="text">search</field>
  <field name="timestamp">2006-02-13T15:26:37Z</field>
  <field name="public">Optimized</field>
  <field name="public">Optimized_data</field>
  <field name="groups">Standards</field>
  <field name="groups">Standards_data</field>
  <field name="sitename">GoInfo</field>
  <field name="context">Scalability</field>
  <field name="modified_date">2010-11-13T15:26:37Z</field>
  </doc></add>

当我尝试将数据重新索引到solr时,如下所示: -

C:\apache-solr-3.2.0\example\exampledocs>java -Durl=http://localhost:7788/solr/u
pdate -jar post.jar *.xml
SimplePostTool: version 1.3
SimplePostTool: POSTing files to http://localhost:7788/solr/update..
SimplePostTool: POSTing file 30-example.xml
SimplePostTool: POSTing file hd.xml
SimplePostTool: POSTing file other.xml
SimplePostTool: FATAL: Solr returned an error #400 Bad Request

我总是在text.xml文件后出错,如果我删除了这个text.xml文件,那么我没有收到任何错误。如果我包含text.xml文件,这就是我得到的以下错误。任何帮助将不胜感激。

SEVERE: org.apache.solr.common.SolrException: Document [null] missing required field: id
        at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:336)
        at org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:60)
        at org.apache.solr.handler.XMLLoader.processUpdate(XMLLoader.java:147)
        at org.apache.solr.handler.XMLLoader.load(XMLLoader.java:77)
        at org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(ContentStreamHandlerBase.java:67)
        at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
        at org.apache.solr.core.SolrCore.execute(SolrCore.java:1360)
        at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
        at java.lang.Thread.run(Thread.java:662)

2 个答案:

答案 0 :(得分:2)

你说你添加了一些字段(据说是示例模式),但你没有提到已经存在的字段发生了什么。我猜你在那里留下了先前存在的字段,这意味着id仍然是必填字段(请参阅示例模式中的here),因此您看到错误。

答案 1 :(得分:1)

制作

  

“主键”ID。这确实是必需的。