# HTML\_strip / highlight combo limitations?

**URL:** <https://discuss.elastic.co/t/html-strip-highlight-combo-limitations/12460>\
**Category:** Elasticsearch\
**Created:** [June 18, 2013, 2:03pm UTC](https://discuss.elastic.co/t/html-strip-highlight-combo-limitations/12460 "2013-06-18T14:03:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [June 18, 2013, 2:03pm UTC](https://discuss.elastic.co/t/html-strip-highlight-combo-limitations/12460/1 "2013-06-18T14:03:35Z")

</div>

Hi,

To me it seems that HTML\_strip char filter and highlighting do not always  
play perfectly together. For example, it can produce invalid HTML output,  
like: "_token_" where _is part of original content and  
  is a tag added by highlighter._

More elaborated full recreation script can be found here:

> <https://gist.github.com/lukas-vlcek/5805393>

I just wanted to check with ML in case I do something wrong on my side. I  
did not check low level details but I would understand that currently it is  
probably not possible to expect the highlighter output to be valid HTML in  
such case.

In other words, HTML\_strip is useful for analysis to remove HTML tags and  
translate HTML entities. But if highlighting is needed it requires for the  
client to provide stripped content in another field.

Regards,  
Lukas

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [June 19, 2013, 9:35am UTC](https://discuss.elastic.co/t/html-strip-highlight-combo-limitations/12460/2 "2013-06-19T09:35:42Z")

</div>

You are correct, HtmlStripCharFilter would compute offsets so that the  
opening tag is before the start offset and the closing tag is before the  
end offset, so this doesn't play nicely with highlighting. This is due to  
the way CharFilters correct offsets. I couldn't find any issue related to  
this problem, so maybe you could open one in Lucene's JIRA?

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [June 19, 2013, 11:12am UTC](https://discuss.elastic.co/t/html-strip-highlight-combo-limitations/12460/3 "2013-06-19T11:12:40Z")

</div>

Yea, may be it is worth opening an issue in Lucene JIRA.

Lukas

On Wed, Jun 19, 2013 at 11:35 AM, Adrien Grand \<  
[adrien.grand@elasticsearch.com](mailto:adrien.grand@elasticsearch.com)\> wrote:

> You are correct, HtmlStripCharFilter would compute offsets so that the  
> opening tag is before the start offset and the closing tag is before the  
> end offset, so this doesn't play nicely with highlighting. This is due to  
> the way CharFilters correct offsets. I couldn't find any issue related to  
> this problem, so maybe you could open one in Lucene's JIRA?
> 
> --  
> Adrien Grand
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:30am UTC](https://discuss.elastic.co/t/html-strip-highlight-combo-limitations/12460/4 "2017-07-06T02:30:23Z")

</div>


