# Html stripped highlighted text from html Content field

**URL:** <https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340>\
**Category:** Elasticsearch\
**Created:** [April 16, 2012, 6:09am UTC](https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340 "2012-04-16T06:09:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [April 16, 2012, 6:09am UTC](https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340/1 "2012-04-16T06:09:54Z")

</div>

Hi ,

I have a content field which is html.  
Is is possible to obtain the html stripped highlighted content ?

Thanks  
Vineeth

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [April 17, 2012, 6:00am UTC](https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340/2 "2012-04-17T06:00:27Z")

</div>

Helooooo ,

Some help here would be greatly appreciated ....

Thanks  
Vineeth

On Mon, Apr 16, 2012 at 11:39 AM, Vineeth Mohan  
[vineethmohan@algotree.com](mailto:vineethmohan@algotree.com)wrote:

> Hi ,
> 
> I have a content field which is html.  
> Is is possible to obtain the html stripped highlighted content ?
> 
> Thanks  
> Vineeth

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [April 17, 2012, 9:04am UTC](https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340/3 "2012-04-17T09:04:53Z")

</div>

On Tue, 2012-04-17 at 11:30 +0530, Vineeth Mohan wrote:

> Helooooo ,
> 
> Some help here would be greatly appreciated ....

Have you tried typing 'html' into the search box on the website 😉

Look at the first result that it suggests

clint

> Thanks  
> Vineeth
> 
> On Mon, Apr 16, 2012 at 11:39 AM, Vineeth Mohan  
> [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com) wrote:  
> Hi ,
> 
> ```
> I have a content field which is html.
> Is is possible to obtain the html stripped highlighted
> content ?
>     
> Thanks
> Vineeth
> 
> ```

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [April 18, 2012, 12:04pm UTC](https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340/4 "2012-04-18T12:04:31Z")

</div>

Yes , i did try this out -

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

But then html stripper only make sure that the html stripped text is given  
for indexing.  
It doesn’t make sure that when highlighted text is extracted from \_source ,  
the stripper is applied.

Thanks  
Vineeth

On Tue, Apr 17, 2012 at 2:34 PM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:

> On Tue, 2012-04-17 at 11:30 +0530, Vineeth Mohan wrote:
> 
> > Helooooo ,
> > 
> > Some help here would be greatly appreciated ....
> 
> Have you tried typing 'html' into the search box on the website 😉
> 
> Look at the first result that it suggests
> 
> clint
> 
> > Thanks  
> > Vineeth
> > 
> > On Mon, Apr 16, 2012 at 11:39 AM, Vineeth Mohan  
> > [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com) wrote:  
> > Hi ,
> > 
> > ```
> > I have a content field which is html.
> > Is is possible to obtain the html stripped highlighted
> > content ?
> > 
> > Thanks
> > Vineeth
> > 
> > ```

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [April 20, 2012, 1:47pm UTC](https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340/5 "2012-04-20T13:47:57Z")

</div>

Currently am getting the highlighted html and stripping out useful text  
from it.  
It will help a lot if someone could point to a way in ES to do the same  
more efficiently.

THanks  
VIneeth

On Wed, Apr 18, 2012 at 5:34 PM, Vineeth Mohan [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com)wrote:

> Yes , i did try this out -  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/htmlstrip-charfilter.html)
> 
> But then html stripper only make sure that the html stripped text is given  
> for indexing.  
> It doesn’t make sure that when highlighted text is extracted from \_source  
> , the stripper is applied.
> 
> Thanks  
> Vineeth
> 
> On Tue, Apr 17, 2012 at 2:34 PM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:
> 
> > On Tue, 2012-04-17 at 11:30 +0530, Vineeth Mohan wrote:
> > 
> > > Helooooo ,
> > > 
> > > Some help here would be greatly appreciated ....
> > 
> > Have you tried typing 'html' into the search box on the website 😉
> > 
> > Look at the first result that it suggests
> > 
> > clint
> > 
> > > Thanks  
> > > Vineeth
> > > 
> > > On Mon, Apr 16, 2012 at 11:39 AM, Vineeth Mohan  
> > > [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com) wrote:  
> > > Hi ,
> > > 
> > > ```
> > > I have a content field which is html.
> > > Is is possible to obtain the html stripped highlighted
> > > content ?
> > > 
> > > Thanks
> > > Vineeth
> > > 
> > > ```

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 21, 2012, 3:08pm UTC](https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340/6 "2012-04-21T15:08:32Z")

</div>

The html stripping part only applies during tokenization, so the  
highlighting will get you back the actual HTML content. You will need to  
strip HTML yourself if you want that behavior.

On Fri, Apr 20, 2012 at 4:47 PM, Vineeth Mohan [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com)wrote:

> Currently am getting the highlighted html and stripping out useful text  
> from it.  
> It will help a lot if someone could point to a way in ES to do the same  
> more efficiently.
> 
> THanks  
> VIneeth
> 
> On Wed, Apr 18, 2012 at 5:34 PM, Vineeth Mohan [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com)wrote:
> 
> > Yes , i did try this out -  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/htmlstrip-charfilter.html)
> > 
> > But then html stripper only make sure that the html stripped text is  
> > given for indexing.  
> > It doesn’t make sure that when highlighted text is extracted from \_source  
> > , the stripper is applied.
> > 
> > Thanks  
> > Vineeth
> > 
> > On Tue, Apr 17, 2012 at 2:34 PM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:
> > 
> > > On Tue, 2012-04-17 at 11:30 +0530, Vineeth Mohan wrote:
> > > 
> > > > Helooooo ,
> > > > 
> > > > Some help here would be greatly appreciated ....
> > > 
> > > Have you tried typing 'html' into the search box on the website 😉
> > > 
> > > Look at the first result that it suggests
> > > 
> > > clint
> > > 
> > > > Thanks  
> > > > Vineeth
> > > > 
> > > > On Mon, Apr 16, 2012 at 11:39 AM, Vineeth Mohan  
> > > > [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com) wrote:  
> > > > Hi ,
> > > > 
> > > > ```
> > > > I have a content field which is html.
> > > > Is is possible to obtain the html stripped highlighted
> > > > content ?
> > > > 
> > > > Thanks
> > > > Vineeth
> > > > 
> > > > ```

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [April 21, 2012, 4:58pm UTC](https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340/7 "2012-04-21T16:58:17Z")

</div>

Thanks Shay ,

But then , i have to see if we use attachment type , then we should be able  
to achieve this behavior .

Thanks  
Vineeth

On Sat, Apr 21, 2012 at 8:38 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> The html stripping part only applies during tokenization, so the  
> highlighting will get you back the actual HTML content. You will need to  
> strip HTML yourself if you want that behavior.
> 
> On Fri, Apr 20, 2012 at 4:47 PM, Vineeth Mohan [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com)wrote:
> 
> > Currently am getting the highlighted html and stripping out useful text  
> > from it.  
> > It will help a lot if someone could point to a way in ES to do the same  
> > more efficiently.
> > 
> > THanks  
> > VIneeth
> > 
> > On Wed, Apr 18, 2012 at 5:34 PM, Vineeth Mohan \<[vineethmohan@algotree.com](mailto:vineethmohan@algotree.com)
> > 
> > > wrote:
> > 
> > > Yes , i did try this out -  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/htmlstrip-charfilter.html)
> > > 
> > > But then html stripper only make sure that the html stripped text is  
> > > given for indexing.  
> > > It doesn’t make sure that when highlighted text is extracted from  
> > > \_source , the stripper is applied.
> > > 
> > > Thanks  
> > > Vineeth
> > > 
> > > On Tue, Apr 17, 2012 at 2:34 PM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:
> > > 
> > > > On Tue, 2012-04-17 at 11:30 +0530, Vineeth Mohan wrote:
> > > > 
> > > > > Helooooo ,
> > > > > 
> > > > > Some help here would be greatly appreciated ....
> > > > 
> > > > Have you tried typing 'html' into the search box on the website 😉
> > > > 
> > > > Look at the first result that it suggests
> > > > 
> > > > clint
> > > > 
> > > > > Thanks  
> > > > > Vineeth
> > > > > 
> > > > > On Mon, Apr 16, 2012 at 11:39 AM, Vineeth Mohan  
> > > > > [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com) wrote:  
> > > > > Hi ,
> > > > > 
> > > > > ```
> > > > > I have a content field which is html.
> > > > > Is is possible to obtain the html stripped highlighted
> > > > > content ?
> > > > > 
> > > > > Thanks
> > > > > Vineeth
> > > > > 
> > > > > ```

---

<div class="post-metadata">

**Author:** ![pellyadolfo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pellyadolfo/32/1879_2.png) [@pellyadolfo](https://discuss.elastic.co/u/pellyadolfo)\
**Post date:** [December 19, 2013, 7:55pm UTC](https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340/8 "2013-12-19T19:55:08Z")

</div>

Hi, I searched documentation and internet but could not find any accurate  
information on this.

I have a highlight query which is working properly:

SearchResponse response = getClient().prepareSearch()  
.setIndices("myindex")  
.setTypes("mytype")  
.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
.setQuery(QueryBuilders  
.boolQuery()  
.should(QueryBuilders.matchQuery("myfield", "house"))  
)  
.addHighlightedField("myfield", 250, 1)  
.setFrom(0)  
.setSize(25)  
.execute()  
.actionGet();

The query is fetching results from myfield which contains indexed HTML  
content. Highlighted result contains HTML tags and would like to trip out  
the HTML content response. I found the HTML Strip Char Filter[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-htmlstrip-charfilter.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-htmlstrip-charfilter.html) but  
do not know what is the syntax to add it as a request analyzer _in Java_.

I have found examples in Java to create indices including the analyzer[http://jaibeermalik.wordpress.com/2013/03/26/elasticsearch-text-analysis-for-content-enrichment/](http://jaibeermalik.wordpress.com/2013/03/26/elasticsearch-text-analysis-for-content-enrichment/) but  
none to include the analyzer in a java request which documentations says[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis.html)is possible:

_The index analysis module acts as a configurable registry of Analyzers  
that can be used in order to both break indexed (analyzed) fields when a  
document is indexed and process query strings_

Any pointer to an example would be very appreciated.

Thanks.

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d83716b0-1461-4796-9d03-b7d7cb268ef7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d83716b0-1461-4796-9d03-b7d7cb268ef7%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 20, 2013, 11:19am UTC](https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340/9 "2013-12-20T11:19:49Z")

</div>

Hey,

you could use the analyze API and the char\_filter to get the extract text  
back in parts, see [HTML Strip charfilter test for ElasticSearch · GitHub](https://gist.github.com/clintongormley/780895)  
However elasticsearch does not store the text without the HTML somewhere as  
a complete block, which you could read out. If you want to do that, you  
would need to do it before indexing.

The char\_filter is basically to make sure that a search for 'title' will  
not include any web page which contains a '' tag.

Not a hundred percent sure if this was your question, so feel free to ask  
further and where I might have misunderstood you.

--Alex

On Thu, Dec 19, 2013 at 8:55 PM, Adolfo Rodriguez [pellyadolfo@yahoo.es](mailto:pellyadolfo@yahoo.es)wrote:

> Hi, I searched documentation and internet but could not find any accurate  
> information on this.
> 
> I have a highlight query which is working properly:
> 
> SearchResponse response = getClient().prepareSearch()  
> .setIndices("myindex")  
> .setTypes("mytype")  
> .setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
> .setQuery(QueryBuilders  
> .boolQuery()  
> .should(QueryBuilders.matchQuery("myfield", "house"))  
> )  
> .addHighlightedField("myfield", 250, 1)  
> .setFrom(0)  
> .setSize(25)  
> .execute()  
> .actionGet();
> 
> The query is fetching results from myfield which contains indexed HTML  
> content. Highlighted result contains HTML tags and would like to trip out  
> the HTML content response. I found the HTML Strip Char Filter[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-htmlstrip-charfilter.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-htmlstrip-charfilter.html) but  
> do not know what is the syntax to add it as a request analyzer _in Java_.
> 
> I have found examples in Java to create indices including the analyzer[http://jaibeermalik.wordpress.com/2013/03/26/elasticsearch-text-analysis-for-content-enrichment/](http://jaibeermalik.wordpress.com/2013/03/26/elasticsearch-text-analysis-for-content-enrichment/) but  
> none to include the analyzer in a java request which documentations says[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis.html)is possible:
> 
> _The index analysis module acts as a configurable registry of Analyzers  
> that can be used in order to both break indexed (analyzed) fields when a  
> document is indexed and process query strings_
> 
> Any pointer to an example would be very appreciated.
> 
> Thanks.
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/d83716b0-1461-4796-9d03-b7d7cb268ef7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d83716b0-1461-4796-9d03-b7d7cb268ef7%40googlegroups.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM840fyahaGQhXQR0nfWf0Y9z8kSXEQJbVETi6rb6R5tdg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM840fyahaGQhXQR0nfWf0Y9z8kSXEQJbVETi6rb6R5tdg%40mail.gmail.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, 1:59am UTC](https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340/10 "2017-07-06T01:59:59Z")

</div>


