0

我正在尝试导入 allemanic wikipedia xml-dump。我指定了一些正则表达式规则来忽略维基百科页面,如类别、文件、模板……这个配置确实可以正常工作。

但后来我想将索引限制为内容字段长度至少为 200 个字符的文档。但我想不出任何办法来做到这一点。我尝试了一些正则表达式,但索引总是会立即失败(似乎不支持 (.*){5} 之类的东西?)。

有谁知道 solr 支持的正则表达式来跳过只有 200 个或更少字符的文档?或者有没有其他方法可以实现这种行为?

<dataConfig>
    <dataSource type="FileDataSource" encoding="UTF-8" />
    <document>
        <entity name="page" processor="XPathEntityProcessor" stream="true" forEach="/mediawiki/page/" url="/home/patrick/Desktop/alswiki-20130413-pages-articles.xml" transformer="RegexTransformer,DateFormatTransformer,HTMLStripTransformer,TemplateTransformer">
            <field column="origid" xpath="/mediawiki/page/id" />
            <field column="id" regex="^(.*)$" replaceWith="als-$1" sourceColName="origid" />
            <field column="name" xpath="/mediawiki/page/title" />
            <field column="revision_id" xpath="/mediawiki/page/revision/id" />
            <field column="user"      xpath="/mediawiki/page/revision/contributor/username" />
            <field column="contents" xpath="/mediawiki/page/revision/text" stripHTML="true" />
            <field column="timestamp" xpath="/mediawiki/page/revision/timestamp" dateTimeFormat="yyyy-MM-dd'T'hh:mm:ss'Z'" />
            <field column="source"  template="Swiss Wiki"/>
            <field column="$skipDoc"  regex="^#REDIRECT.*" replaceWith="true" sourceColName="contents"/>
            <field column="$skipDoc"  regex="^#WEITERLEITUNG.*" replaceWith="true" sourceColName="contents"/>
            <field column="$skipDoc"  regex="^#Redirect.*" replaceWith="true" sourceColName="contents"/>
            <field column="$skipDoc"  regex="^Wikipedia:.*" replaceWith="true" sourceColName="name"/>
            <field column="$skipDoc"  regex="^MediaWiki:.*" replaceWith="true" sourceColName="name"/>
            <field column="$skipDoc"  regex="^Vorlage:.*" replaceWith="true" sourceColName="name"/>
            <field column="$skipDoc"  regex="^Datei:.*" replaceWith="true" sourceColName="name"/>
            <field column="$skipDoc"  regex="^Hilfe:.*" replaceWith="true" sourceColName="name"/>
            <field column="$skipDoc"  regex="^Portal:.*" replaceWith="true" sourceColName="name"/>
            <field column="$skipDoc"  regex="^Kategorie:.*" replaceWith="true" sourceColName="name"/>
        </entity>
    </document>
</dataConfig>
4

1 回答 1

0

首先,(.*){5}将完全匹配 5 个字符。(.*){5,}将匹配五个或更多。因此,对于 200,它将是(.*){200,}.

如果这不起作用,编写自定义转换器相当容易:

http://wiki.apache.org/solr/DIHCustomTransformer

于 2013-04-28T20:12:48.460 回答