Solr Highlighting Problem

2019-05-13 04:06发布

问题:

Hi All I have a problem that when i Query Solr it matches results, but when i enable highlighting on the results of this query the highlighting does not work..

My Query is

+Contents:"item 503"

Contents is of type text and one important thing in text item 503 appear as "item 503(c)", can open parenthesis at the end create problem?? please help

here is highlighting section in SolrSonfig.xml

  <highlighting>
   <!-- Configure the standard fragmenter -->
   <!-- This could most likely be commented out in the "default" case -->
   <fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
    <lst name="defaults">
     <int name="hl.fragsize">100</int>
    </lst>
   </fragmenter>

   <!-- A regular-expression-based fragmenter (f.i., for sentence extraction) -->
   <fragmenter name="regex" class="org.apache.solr.highlight.RegexFragmenter">
    <lst name="defaults">
      <!-- slightly smaller fragsizes work better because of slop -->
      <int name="hl.fragsize">70</int>
      <!-- allow 50% slop on fragment sizes -->
      <float name="hl.regex.slop">0.5</float>
      <!-- a basic sentence pattern -->
      <str name="hl.regex.pattern">[-\w ,/\n\"']{20,200}</str>
    </lst>
   </fragmenter>

   <!-- Configure the standard formatter -->
   <formatter name="html" class="org.apache.solr.highlight.HtmlFormatter" default="true">
    <lst name="defaults">
     <str name="hl.simple.pre"><![CDATA[<em>]]></str>
     <str name="hl.simple.post"><![CDATA[</em>]]></str>
    </lst>
   </formatter>
  </highlighting>

and here is fieldtype definition in schema.xml

  <fieldtype name="text" class="solr.TextField">
    <analyzer>
      <tokenizer class="solr.StandardTokenizerFactory" luceneMatchVersion="LUCENE_29"/>
      <filter class="solr.StandardFilterFactory"/>
     <!-- <filter class="solr.LowerCaseFilterFactory"/>
      <filter class="solr.StopFilterFactory" luceneMatchVersion="LUCENE_29"/>
      <filter class="solr.EnglishPorterFilterFactory"/>-->
    </analyzer>
  </fieldtype>

and here is field definition

<field name="Contents" type="text" indexed="true" stored="true" />

Regards Ahsan.

回答1:

Have you tried storing the term vectors too? If you're using the fast vector highlighter (which I think Solr might by default) you'll need those.



标签: lucene solr