Solr DIH regextransformer - 仅处理一条CSV线

时间:2016-06-04 10:46:22

标签: regex csv solr dataimporthandler dih

您好我有以下CSV文件

132 1536130302256087040
133 1536130302256087041
134 1536130302256087042

字段由选项卡分隔。 现在我有soli的Dataimporthandler(DIH),我尝试将CS​​V导入solr,但我只将第一行导入solr。这是结果,但CSV中的其他行丢失了:

  "response": {
    "numFound": 1,
    "start": 0,
    "maxScore": 1,
    "docs": [ {
        "string": "1536130302256087040",
        "id": "132",
        "_version_": 1536202153221161000
      } ] }

这是我的data-config.xml

<dataConfig>
<dataSource type="FileDataSource" encoding="UTF-8" name="fds"/>
    <document>

     <entity name="f" 
     processor="FileListEntityProcessor" 
     fileName="myfile.csv" 
     baseDir="/var/www/solr-5.4.0/server/csv/files" 
     recursive="false" 
     rootEntity="true" 
     dataSource="null" >

     <entity 
     onError="continue" 
     name="jc"   
     processor="LineEntityProcessor" 
     url="${f.fileAbsolutePath}" 
     dataSource="fds"  
     rootEntity="true" 
     header="false"
     separator="\t"
     transformer="RegexTransformer" >

     <field column="id" name="id" sourceColName="rawLine" regex="^(.*)\t"/>
     <field column="string" name="string" sourceColName="rawLine" regex="\t(.*)$"/>

             </entity>            
        </entity>
    </document>
</dataConfig>

这是我的schema.xml

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

 <uniqueKey>id</uniqueKey>

我做错了什么?

1 个答案:

答案 0 :(得分:2)

对于两个级别的实体,您都有 rootEntity = true 。因此,您只能获得外部实体的一个文档。尝试将外层rootEntity设置为false。

此外,您只需将标签分隔的文件发送到Solr CSV processor,无需DIH。

相关问题