[英]Solr index xml file with html tag (with DataImportHandler)
I have Solr 4.10.4 and I would like to index a xml file. 我有Solr 4.10.4,我想索引一个xml文件。 Somes xml tags contain html tags.
某些xml标签包含html标签。
<?xml version='1.0' encoding='UTF-8' standalone='no' ?>
<root>
<info>
<text>
<p>text 1</p>
<p>text 2</p>
<p>text 3</p>
</text>
</info>
</root>
I used this : 我用这个:
<charFilter class="solr.HTMLStripCharFilterFactory"/>
but it does not work and I don't know what is wrong. 但这是行不通的,我也不知道哪里出了问题。
M. M.
HTMLStripCharFilterFactory is going to strip the HTML tage from indexed data not from the stored. HTMLStripCharFilterFactory将从被索引的数据而不是从存储的数据中剥离HTML 年龄 。
To strip html tags while indexing you can use HTMLStripTransformer in dataimporthandler. 要在索引时去除 html标签,可以在dataimporthandler中使用HTMLStripTransformer 。 Below is the sample DIH for the same.
以下是相同的示例DIH。
<dataConfig>
<dataSource name="fDS" type="FileDataSource" />
<document>
<entity name="tika-test" processor="XPathEntityProcessor"
url="${solr.install.dir}/example/exampledocs/content.xml" forEach="/root" dataSource="fDS">
<field column="text" xpath="/root/info/text/p" />
</entity>
</document>
There is one attribute for this transformer, stripHTML, which is a boolean value (true/false) to signal if the HTMLStripTransformer should process the field or not. 此转换器有一个属性stripHTML,它是一个布尔值(真/假),用于表示HTMLStripTransformer是否应处理该字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.