【问题标题】:Solr DIH regextransformer - processes only one CSV lineSolr DIH regextransformer - 仅处理一条 CSV 行
【发布时间】:2016-06-05 19:36:10
【问题描述】:

您好,我有以下 CSV 文件

132 1536130302256087040
133 1536130302256087041
134 1536130302256087042

字段由制表符分隔。 现在我有 solr 的 Dataimporthandler (DIH),我尝试将 CSV 导入 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>

我做错了什么?

【问题讨论】:

    标签: regex csv solr dataimporthandler dih


    【解决方案1】:

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

    此外,您可以使用CSV processor 将制表符分隔的文件发送到 Solr,无需 DIH。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      相关资源
      最近更新 更多