将solr.jar与Apache Solr 3.6下载中的示例一起使用,HTML标记不会被剥离。
在schema.xml中,我添加了以下内容:
<!-- A text field that only splits on whitespace for exact matching of words -->
<fieldType name="text_html" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<charFilter class="solr.HTMLStripCharFilterFactory"/>
<tokenizer class="solr.StandardTokenizerFactory"/>
</analyzer>
</fieldType>
<field name="title" type="text_html" indexed="true" stored="true" multiValued="true"/>
另外,我将以下JSON发布到SOLR:
[
{
"id" : "978-064172344522",
"title":"my <a href=\"www.foo.bar\">link</a> power-shot PowerShot USC Utility <br>hello</br> Rejections Under 35 U.S.C. 101 and 35 U.S.C. 112, First Paragraph Petitions to correct inventorship of an issued patent are decided by the <Underline>Supervisory Patent Examiner</Underline>, as set forth"
}
重新启动SOLR后,我进行了强力搜索,结果仍显示HTML标记
<result name="response" numFound="1" start="0" maxScore="0.13561106">
<doc>
<float name="score">0.13561106</float>
<str name="id">978-064172344522</str>
<arr name="title">
<str>my <a href="www.foo.bar">link</a> power-shot PowerShot USC Utility <br>hello</br>
这里缺少什么?
答案 0 :(得分:2)
您看到的是最初发送给Solr的存储字段。例如,如果您搜索'title:href',则不应该找到该文档,因为在Analyzer链中应删除html内容