0
votes

I have a problem related to highlighting multivalue field in Solr response. How can i highlight multivalue field which matched with my solr filter query? Below is the kind of my document,

<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&#95;Label&#32;for&#32;UK&#32;2&#95;Label&#32;for&#32;US&#32;4&#95;Label&#32;for&#32;FR</str>
</arr>
</lst>
</lst>

Now querying with CITIES:*DEL*, the solr highlighted response should returns only those cities which contains DEL in its word. How can i achieve this?

Is there any idea or suggestions about how to sort out this?

Looking for positive response from all of you solr geeks...

Thanks in advance for your support.

Regards, Ashish Mishra

1
Can you provide the exact query? And the field types you are using for "CITIES"? How is the highlight component defined in your SolrConfig? I just ran a query on one of my Solr servers doing a fuzzy search as you did, and I can see highlights. Can you also paste the exact response you are getting from your query? What version of Solr are you using?jay
Dear Jay, First of all thanks for your interest. I have updated my post with solr config and highlighter component with solr response as well as solr query.Ashish Mishra

1 Answers

0
votes

As the parameter name indicates, the multiValuedSeparatorChar should be a single character. Don't you get an exception like this?

null:java.lang.IllegalArgumentException: hl.multiValuedSeparatorChar must be exactly one character.

So I recommend using a single character:

<str name="hl.multiValuedSeparatorChar">#</str>