6

我在使用 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>

每当我运行更新时,都会插入一些文档 ok ,购买很多返回:

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

1 回答 1

8

通过链接上的示例,它应该是

<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>
于 2013-06-04T09:43:30.553 回答