# Stripping html for indexing only?

**URL:** <https://discuss.elastic.co/t/stripping-html-for-indexing-only/19125>\
**Category:** Elasticsearch\
**Created:** [August 6, 2014, 6:45pm UTC](https://discuss.elastic.co/t/stripping-html-for-indexing-only/19125 "2014-08-06T18:45:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![IronMike](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@IronMike](https://discuss.elastic.co/u/IronMike)\
**Post date:** [August 6, 2014, 6:45pm UTC](https://discuss.elastic.co/t/stripping-html-for-indexing-only/19125/1 "2014-08-06T18:45:51Z")

</div>

I searched this topic but some of the answers were still vague to me.

My goal is to index html docs but have the html stripped for the indexing,  
at the same time, I would like \_source to have the original html document  
for display purposes.

//My doc format:  
{  
content: Hello this is an html **content**....  
rank:1  
date:2014-8-8  
title: Some title  
....  
}

The questions that I am still not very clear on:

1 - if I understand correctly, I can push html doc like it is to Index, and  
it will strip html provided I do the charfilter referenced here?

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

2- Will the stripping not affect the \_source? In other words, \_source will  
still have the original html?

3- Highlighting comes from the \_source? this means highlighting will have  
html, meaning I will have to strip any html tags after the search comes  
back?

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/6be77d25-f7fe-4a35-a247-932f93f07150%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6be77d25-f7fe-4a35-a247-932f93f07150%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [August 6, 2014, 6:59pm UTC](https://discuss.elastic.co/t/stripping-html-for-indexing-only/19125/2 "2014-08-06T18:59:38Z")

</div>

1. Correct.
2. Also correct. The analysis chain only affects how the terms are indexed  
and placed in the inverted index. The original document remains as is.
3. Not sure since I have never done highlighting. Highlighting might not  
depend on the source since the term positions/offsets are used, but  
hopefully someone will correct me.

--  
Ivan

On Wed, Aug 6, 2014 at 11:45 AM, IronMike [sabdalla80@gmail.com](mailto:sabdalla80@gmail.com) wrote:

> I searched this topic but some of the answers were still vague to me.
> 
> My goal is to index html docs but have the html stripped for the indexing,  
> at the same time, I would like \_source to have the original html document  
> for display purposes.
> 
> //My doc format:  
> {  
> content: Hello this is an html **content**....  
> rank:1  
> date:2014-8-8  
> title: Some title  
> ....  
> }
> 
> The questions that I am still not very clear on:
> 
> 1 - if I understand correctly, I can push html doc like it is to Index,  
> and it will strip html provided I do the charfilter referenced here?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-htmlstrip-charfilter.html)
> 
> 2- Will the stripping not affect the \_source? In other words, \_source will  
> still have the original html?
> 
> 3- Highlighting comes from the \_source? this means highlighting will have  
> html, meaning I will have to strip any html tags after the search comes  
> back?
> 
> 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/6be77d25-f7fe-4a35-a247-932f93f07150%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6be77d25-f7fe-4a35-a247-932f93f07150%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/6be77d25-f7fe-4a35-a247-932f93f07150%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/6be77d25-f7fe-4a35-a247-932f93f07150%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CALY%3DcQBfhWBqtfi0zfPvmYs9ytT-bz75U8vCsuuUo3GVvLugpA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBfhWBqtfi0zfPvmYs9ytT-bz75U8vCsuuUo3GVvLugpA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![IronMike](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@IronMike](https://discuss.elastic.co/u/IronMike)\
**Post date:** [August 7, 2014, 4:37pm UTC](https://discuss.elastic.co/t/stripping-html-for-indexing-only/19125/3 "2014-08-07T16:37:06Z")

</div>

Thanks. I tried a simple example below and it doesn't seem to strip html,  
What's missing?

//yml  
index :  
analysis :  
analyzer :  
messageAnalyzer :  
type : custom  
tokenizer : standard  
filter : standard  
char\_filter : [my\_html]  
char\_filter :  
my\_html :  
type : html\_strip  
read\_ahead : 1024

//Create Index  
PUT /twitter  
{  
"mappings": {  
"message" : {  
"properties" : {  
"message" : {  
"type" : "string",  
"analyzer": "messageAnalyzer"  
},  
"date" : {  
"type" : "date"  
},  
"name" : {  
"type" : "string"  
}  
}  
}  
}  
}

//Index a document  
PUT /twitter/tweet/1  
{  
"name" : "mike",  
"date" : "2009-11-15T14:12:12",  
"message" : "trying out **Elasticsearch** , This is an html  
test"  
}

//Search for "Elasticsearch" yields html still  
"fields": {  
"message": [  
"trying out **Elasticsearch** , This is an html  
test"  
]

On Wednesday, August 6, 2014 2:59:53 PM UTC-4, Ivan Brusic wrote:

> 1. Correct.
> 2. Also correct. The analysis chain only affects how the terms are indexed  
> and placed in the inverted index. The original document remains as is.
> 3. Not sure since I have never done highlighting. Highlighting might not  
> depend on the source since the term positions/offsets are used, but  
> hopefully someone will correct me.
> 
> --  
> Ivan
> 
> On Wed, Aug 6, 2014 at 11:45 AM, IronMike \<[sabda...@gmail.com](mailto:sabda...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > I searched this topic but some of the answers were still vague to me.
> > 
> > My goal is to index html docs but have the html stripped for the  
> > indexing, at the same time, I would like \_source to have the original html  
> > document for display purposes.
> > 
> > //My doc format:  
> > {  
> > content: Hello this is an html **content**....  
> > rank:1  
> > date:2014-8-8  
> > title: Some title  
> > ....  
> > }
> > 
> > The questions that I am still not very clear on:
> > 
> > 1 - if I understand correctly, I can push html doc like it is to Index,  
> > and it will strip html provided I do the charfilter referenced here?
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-htmlstrip-charfilter.html)
> > 
> > 2- Will the stripping not affect the \_source? In other words, \_source  
> > will still have the original html?
> > 
> > 3- Highlighting comes from the \_source? this means highlighting will have  
> > html, meaning I will have to strip any html tags after the search comes  
> > back?
> > 
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/6be77d25-f7fe-4a35-a247-932f93f07150%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6be77d25-f7fe-4a35-a247-932f93f07150%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/6be77d25-f7fe-4a35-a247-932f93f07150%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/6be77d25-f7fe-4a35-a247-932f93f07150%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/87574845-6195-4904-bb1f-d8e9c662c177%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/87574845-6195-4904-bb1f-d8e9c662c177%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:10am UTC](https://discuss.elastic.co/t/stripping-html-for-indexing-only/19125/4 "2017-07-06T01:10:08Z")

</div>


