Nándor Mátravölgyi created SOLR-14019:
-----------------------------------------

             Summary: Inconsistent HTML escaping with highlighters
                 Key: SOLR-14019
                 URL: https://issues.apache.org/jira/browse/SOLR-14019
             Project: Solr
          Issue Type: Bug
      Security Level: Public (Default Security Level. Issues are Public)
          Components: highlighter
            Reporter: Nándor Mátravölgyi


The unified highlighter does not use the 
*org.apache.lucene.search.highlight.SimpleHTMLEncoder* through 
*org.apache.solr.highlight.HtmlEncoder*. It has the HTML escaping feature 
re-implemented and embedded in the  
*org.apache.lucene.search.uhighlight.DefaultPassageFormatter*.

The HTML escaping done by the unified highlighter escapes characters that do 
not need it. This makes the result payload 50%+ more heavy with no benefit.

Here is a highlight snippet using the original highlighter:
{noformat}
A <em>filter</em> that stems words using a Snowball-generated stemmer. 
Available stemmers &amp; x are listed in org.tartarus.snowball.ext. Note: This 
<em>filter</em> is aware of the KeywordAttribute.
{noformat}

Here is the same highlight snippet using the unified highlighter:
{noformat}
A&#32;<em>filter</em>&#32;that&#32;stems&#32;words&#32;using&#32;a&#32;Snowball&#45;generated&#32;stemmer&#46;&#32;Available&#32;stemmers&#32;&amp;&#32;x&#32;are&#32;listed&#32;in&#32;org&#46;tartarus&#46;snowball&#46;ext&#46;&#32;Note&#58;&#32;This&#32;<em>filter</em>&#32;is&#32;aware&#32;of&#32;the&#32;KeywordAttribute&#46;
{noformat}

Maybe I'm missing the point why this is done the way it is. If this behaviour 
is desired for some use-case it should be a separate encoder, and the HTML 
encoder should only escape the necessary characters.

Affects all versions of Solr. Here are the lines where the escaping are 
implemented differently:
* [Escaping by the unified 
highlighter|https://github.com/apache/lucene-solr/blob/2387bb9d60ae44eeeb4fbcb2f2877f46be5303a0/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/DefaultPassageFormatter.java#L132]
* [Escaping by the other 
highlighters|https://github.com/apache/lucene-solr/blob/2387bb9d60ae44eeeb4fbcb2f2877f46be5303a0/lucene/highlighter/src/java/org/apache/lucene/search/highlight/SimpleHTMLEncoder.java#L69]




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to