# 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:** 1\
**Showing post:** 9

<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).

---

_[View the full topic](https://discuss.elastic.co/t/html-stripped-highlighted-text-from-html-content-field/7340)._
