我遇到与在Solr响应中突出显示多值字段有关的问题。如何突出显示与我的solr过滤器查询匹配的多值字段?以下是我的文档,
<doc>
<str name="id">CAID_332_1003</str>
<arr name="lang_spec_labels">
<str>1_Label for UK</str>
<str>2_Label for US</str>
<str>4_Label for FR</str>
</arr>
</doc>
#My solr config details
<requestHandler name="/select" class="solr.StandardRequestHandler">
<lst name="defaults">
<str name="hl">on</str>
<str name="hl.fl">lang_spec_labels</str>
<str name="hl.encoder">html</str>
<bool name="hl.preserveMulti">false</bool>
<bool name="hl.useFastVectorHighlighter">true</bool>
<str name="f.lang_spec_labels.hl.fragsize">100</str>
<str name="f.lang_spec_labels.hl.alternateField">lang_spec_labels</str>
<str name="f.lang_spec_labels.hl.maxAlternateFieldLength">750</str>
<str name="hl.bs.type">SENTENCE</str>
</lst>
</requestHandler>
<searchComponent class="solr.HighlightComponent" name="highlight">
<highlighting class="org.apache.solr.highlight.PostingsSolrHighlighter">
<fragmentsBuilder name="default" default="true" class="solr.highlight.ScoreOrderFragmentsBuilder">
<lst name="defaults">
<str name="hl.multiValuedSeparatorChar">##</str>
</lst>
</fragmentsBuilder>
<encoder name="html" class="solr.highlight.HtmlEncoder" />
<formatter name="html"
default="true"
class="solr.highlight.HtmlFormatter">
<lst name="defaults">
<str name="hl.simple.pre"><![CDATA[<em>]]></str>
<str name="hl.simple.post"><![CDATA[</em>]]></str>
</lst>
</formatter>
</highlighting>
</searchComponent>
My Solr query like q=lang_spec_labels:(1_*)
My Solr Response
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">7</int>
</lst>
<result name="response" numFound="1" start="0">
<doc>
<arr name="lang_spec_labels">
<str>1_Label for UK</str>
<str>2_Label for US</str>
<str>4_Label for FR</str>
</arr></doc>
</result>
<lst name="highlighting">
<lst name="CAID_332_1003">
<arr name="lang_spec_labels">
<str>1_Label for UK 2_Label for US 4_Label for FR</str>
</arr>
</lst>
</lst>
现在使用CITIES:*DEL*
查询,solr突出显示的响应应仅返回其单词中包含DEL的那些城市。我怎样才能做到这一点?
对于如何解决这个问题有任何想法或建议吗?
寻找所有solr极客的积极回应......
提前感谢您的支持。
此致 Ashish Mishra
答案 0 :(得分:0)
如参数名称所示,multiValuedSeparatorChar应为单个字符。你不能得到这样的例外吗?
null:java.lang.IllegalArgumentException: hl.multiValuedSeparatorChar must be exactly one character.
所以我建议使用一个字符:
<str name="hl.multiValuedSeparatorChar">#</str>