【问题标题】:Solr Regex - parse tab seperated CSVSolr Regex - 解析制表符分隔的 CSV
【发布时间】:2016-06-06 14:48:24
【问题描述】:

您好,我有一个 CSV,它由每个字段的选项卡分隔:

id  name    subject description comments
c4e 10181   Hello1  d1  1
741 10181   Hello2  d2  2
b62 10181   Hello3  d3  3
fd4 10181   Hello4  d4  4
2fb 10181   Hello5  d5  5

我想用 solr Regextransformer 对其进行正则表达式,通过 Dataimporthandler (DIH) 导入它,但最终正则表达式不起作用:

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

Subject, decriction 和 cmets 都错了,它们额外取了前面的字段,正则表达式有什么问题?

【问题讨论】:

标签: csv solr dataimporthandler dih


【解决方案1】:

根据你的描述,我会说这是一个贪婪的问题。将最后 3 行中每次出现的 .* 替换为 .*? 是否有帮助?

【讨论】:

    猜你喜欢
    • 2019-02-03
    • 2011-12-12
    • 1970-01-01
    • 1970-01-01
    • 2013-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多