title: highlighting exact phrases with solr
body: <p>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.</p>
  
  <p>For example if the keyword is: "dulce hogar" 
  it returns:</p>
  
  <pre><code>&lt;i&gt; dulce &lt;/i&gt; &lt;i&gt; hogar &lt;/i&gt; 
  </code></pre>
  
  <p>And it should be: </p>
  
  <pre><code>&lt;i&gt; dulce hogar &lt;/i&gt; 
  </code></pre>
  
  <p>I don't understand which is the problem.</p>
  
  <p>My configuration in schema.xml</p>
  
  <pre><code> &lt;fieldType name="text_general" class="solr.TextField" positionIncrementGap="100"&gt;
       &lt;analyzer type="index"&gt;
      &lt;tokenizer class="solr.WhitespaceTokenizerFactory"/&gt;
      &lt;filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"  /&gt;
      &lt;!-- in this example, we will only use synonyms at query time
      &lt;filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt"   ignoreCase="true" expand="false"/&gt;
      --&gt;
      &lt;filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0"/&gt;
      &lt;filter class="solr.LowerCaseFilterFactory"/&gt;
      &lt;filter class="solr.RemoveDuplicatesTokenFilterFactory"/&gt;
    &lt;/analyzer&gt;
    &lt;analyzer type="query"&gt;
      &lt;tokenizer class="solr.WhitespaceTokenizerFactory"/&gt;
      &lt;filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /&gt;
      &lt;filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/&gt;
      &lt;filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="1"/&gt;
      &lt;filter class="solr.RemoveDuplicatesTokenFilterFactory"/&gt;
      &lt;filter class="solr.LowerCaseFilterFactory"/&gt;
    &lt;/analyzer&gt;
  &lt;/fieldType&gt;
  </code></pre>
  
  <p>And in solrconfig.xml</p>
  
  <pre><code> &lt;requestHandler name="/select" class="solr.SearchHandler"&gt;
  
      &lt;lst name="defaults"&gt;
    &lt;str name="echoParams"&gt;explicit&lt;/str&gt;
    &lt;int name="rows"&gt;10&lt;/int&gt;
     &lt;str name="df"&gt;text&lt;/str&gt;
    &lt;bool name="hl.usePhraseHighlighter"&gt;true&lt;/bool&gt;
  &lt;/lst&gt;
  
  
   &lt;/requestHandler&gt;
  &lt;!-- Highlighting Component
  
     http://wiki.apache.org/solr/HighlightingParameters
  --&gt;
  &lt;searchComponent class="solr.HighlightComponent" name="highlight"&gt;
  &lt;highlighting&gt;
    &lt;!-- Configure the standard fragmenter --&gt;
    &lt;!-- This could most likely be commented out in the "default" case --&gt;
    &lt;fragmenter name="gap" 
                default="true"
                class="solr.highlight.GapFragmenter"&gt;
      &lt;lst name="defaults"&gt;
        &lt;int name="hl.fragsize"&gt;100&lt;/int&gt;
      &lt;/lst&gt;
    &lt;/fragmenter&gt;
  
    &lt;!-- A regular-expression-based fragmenter 
         (for sentence extraction) 
      --&gt;
    &lt;fragmenter name="regex" 
                class="solr.highlight.RegexFragmenter" default="true"&gt;
      &lt;lst name="defaults"&gt;
        &lt;!-- slightly smaller fragsizes work better because of slop --&gt;
        &lt;int name="hl.fragsize"&gt;70&lt;/int&gt;
        &lt;!-- allow 50% slop on fragment sizes --&gt;
        &lt;float name="hl.regex.slop"&gt;0.5&lt;/float&gt;
        &lt;!-- a basic sentence pattern --&gt;
        &lt;str name="hl.regex.pattern"&gt;[-\w ,/\n\&amp;quot;&amp;apos;]{20,200}&lt;/str&gt;
        &lt;bool name="hl.usePhraseHighlighter"&gt;true&lt;/bool&gt;
        &lt;bool name="hl.highlightMultiTerm"&gt;true&lt;/bool&gt;
      &lt;/lst&gt;
    &lt;/fragmenter&gt;
  
    &lt;!-- Configure the standard formatter --&gt;
    &lt;formatter name="html" 
               default="true"
               class="solr.highlight.HtmlFormatter"&gt;
      &lt;lst name="defaults"&gt;
        &lt;str name="hl.simple.pre"&gt;&lt;![CDATA[&lt;em&gt;]]&gt;&lt;/str&gt;
        &lt;str name="hl.simple.post"&gt;&lt;![CDATA[&lt;/em&gt;]]&gt;&lt;/str&gt;
      &lt;/lst&gt;
    &lt;/formatter&gt;
  </code></pre>
  
  <p>Thanks for some help in advance,</p>
  
  <p>Sil.</p>