I am using solrj as client for indexing documents on the solr server I am
new to solr, And I am having problem with the highlighting in solr.
Highlighting exact phrases with solr does not work.

For example if the search keyword is: "dulce hogar" it returns:

<span class="item"> dulce </span> <span class="item"> hogar </span>

 And it should be:

<span class="item"> dulce hogar </span>

I don't understand which is the problem. Can someone  helpme please!?


Mi Solrj program code is:


        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setQuery(queryEnt);
        solrQuery.set("collectionName", myCollection);
        solrQuery.addHighlightField("texto")
                 .addHighlightField("titular")
                 .setHighlightSnippets(50)
                 .setHighlightFragsize(1);
        solrQuery.setHighlight(true);
        solrQuery.setHighlightRequireFieldMatch(true);


        //solrQuery.setHighlightRequireFieldMatch(true);
        solrQuery.setHighlightSimplePre("<span class=\"item\">");
        solrQuery.setHighlightSimplePost("</span>");


        solrQuery.set("hl.usePhraseHighlighter", true);



My configuration in schema.xml


<fieldType name="text_general" class="solr.TextField"
positionIncrementGap="100">
     <analyzer type="index">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt"  />
    <!-- in this example, we will only use synonyms at query time
    <filter class="solr.SynonymFilterFactory"
synonyms="index_synonyms.txt"   ignoreCase="true" expand="false"/>
    -->
    <filter class="solr.WordDelimiterFilterFactory"
generateWordParts="1" generateNumberParts="1" catenateWords="1"
catenateNumbers="1" catenateAll="0"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt" />
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
ignoreCase="true" expand="true"/>
    <filter class="solr.WordDelimiterFilterFactory"
generateWordParts="1" generateNumberParts="1" catenateWords="1"
catenateNumbers="1" catenateAll="1"/>
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>


And in solrconfig.xml

 <requestHandler name="/select" class="solr.SearchHandler">

    <lst name="defaults">
  <str name="echoParams">explicit</str>
  <int name="rows">10</int>
   <str name="df">text</str>
  <bool name="hl.usePhraseHighlighter">true</bool>
</lst>


 </requestHandler>
<!-- Highlighting Component

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

  <!-- A regular-expression-based fragmenter
       (for sentence extraction)
    -->
  <fragmenter name="regex"
              class="solr.highlight.RegexFragmenter" default="true">
    <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\&quot;&apos;]{20,200}</str>
      <bool name="hl.usePhraseHighlighter">true</bool>
      <bool name="hl.highlightMultiTerm">true</bool>
    </lst>
  </fragmenter>

  <!-- Configure the standard formatter -->
  <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>


missing anything?

Thanks a lot for some help in advance,
Silvia



*
*
*Tecnologías y SaaS para el análisis de marcas comerciales.*


Nota:
Usted ha recibido este mensaje al estar en la libreta de direcciones del
remitente, en los archivos de la empresa o mediante el sistema de
“responder” al ser usted la persona que contactó por este medio con el
remitente. En caso de no querer recibir ningún email mas del remitente o de
cualquier miembro de la organización a la que pertenece, por favor,
responda a este email solicitando la baja de su dirección en nuestros
archivos.

Advertencia legal:
Este mensaje y, en su caso, los ficheros anexos son confidenciales,
especialmente en lo que respecta a los datos personales, y se dirigen
exclusivamente al destinatario referenciado. Si usted no lo es y lo ha
recibido por error o tiene conocimiento del mismo por cualquier motivo, le
rogamos que nos lo comunique por este medio y proceda a destruirlo o
borrarlo, y que en todo caso se abstenga de utilizar, reproducir, alterar,
archivar o comunicar a terceros el presente mensaje y ficheros anexos, todo
ello bajo pena de incurrir en responsabilidades legales.

Reply via email to