Solr 4 - 缺少必填字段:uuid

时间:2013-06-04 09:32:38

标签: apache solr lucene solr4 dih

我在使用Solr4中的dataImportHandler生成UUID时遇到问题。我试图从现有的MySQL数据库导入。

我的schema.xml包含:

<fields>

    <field name="uuid" type="uuid" indexed="true" stored="true" required="true" />

    <field name="id" type="string" indexed="true" stored="true" required="true"/>
    <field name="address" type="text_general" indexed="true" stored="true"/>
    <field name="city" type="text_general" indexed="true" stored="true" />
    <field name="county" type="string" indexed="true" stored="true" />
    <field name="lat" type="text_general" indexed="true" stored="true" />
    <field name="lng" type="text_general" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />
    <field name="price"  type="float" indexed="true" stored="true"/>
    <field name="bedrooms" type="float" indexed="true" stored="true" />
    <field name="image" type="string" indexed="true" stored="true"/>

    <field name="region" type="location_rpt" indexed="true" stored="true" />       

    <defaultSearchField>address</defaultSearchField>

    <field name="_version_" type="long" indexed="true" stored="true"/>
    <field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>

 </fields>

 <uniqueKey>uuid</uniqueKey>

然后在<types>

  <fieldType name="uuid" class="solr.UUIDField" indexed="true" />

我的Solrconfig.xml包含:

 <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">  

  <updateRequestProcessorChain name="uuid">
      <processor class="solr.UUIDUpdateProcessorFactory">
          <str name="fieldName">uuid</str>
      </processor>
      <processor class="solr.RunUpdateProcessorFactory" />
  </updateRequestProcessorChain>

 <lst name="defaults">
    <str name="config">data-config.xml</str>
 </lst>

每当我运行更新时,都会插入一些文档,使用以下内容购买许多文档:

org.apache.solr.common.SolrException: [doc=204] missing required field: uuid

1 个答案:

答案 0 :(得分:8)

link为例,它应该是

<requestHandler name="/dataimport"  class="org.apache.solr.handler.dataimport.DataImportHandler">  
    .........
    <lst name="defaults">
        <str name="config">data-config.xml</str>
        <str name="update.chain">uuid</str>
    </lst>
</requestHandler>

<updateRequestProcessorChain name="uuid">
  <processor class="solr.UUIDUpdateProcessorFactory">
      <str name="fieldName">uuid</str>
  </processor>
  <processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>