# How can I strip text from a document before it goes into the index

**URL:** <https://discuss.elastic.co/t/how-can-i-strip-text-from-a-document-before-it-goes-into-the-index/109589>\
**Category:** Elasticsearch\
**Created:** [November 29, 2017, 12:17pm UTC](https://discuss.elastic.co/t/how-can-i-strip-text-from-a-document-before-it-goes-into-the-index/109589 "2017-11-29T12:17:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bilpor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bilpor/32/24043_2.png) [@bilpor](https://discuss.elastic.co/u/bilpor)\
**Post date:** [November 29, 2017, 12:17pm UTC](https://discuss.elastic.co/t/how-can-i-strip-text-from-a-document-before-it-goes-into-the-index/109589/1 "2017-11-29T12:17:48Z")

</div>

HI All,

I have created an index of an intranet site that is written in classic asp. The idea being that a search can be performed of the entire site. The trouble is in the content I also have my vbscript that are in '\<% %\>' tags. When I first create the index is there any kind of filter that I can apply to say 'do not include anything between the above tags' in the document?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 29, 2017, 12:38pm UTC](https://discuss.elastic.co/t/how-can-i-strip-text-from-a-document-before-it-goes-into-the-index/109589/2 "2017-11-29T12:38:16Z")

</div>

Depending on if you want to keep the source intact or not you can use a regex token filter or use an ingest grok processor.

---

<div class="post-metadata">

**Author:** ![bilpor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bilpor/32/24043_2.png) [@bilpor](https://discuss.elastic.co/u/bilpor)\
**Post date:** [November 29, 2017, 1:24pm UTC](https://discuss.elastic.co/t/how-can-i-strip-text-from-a-document-before-it-goes-into-the-index/109589/3 "2017-11-29T13:24:25Z")

</div>

No, the actual asp page obviously needs to stay as is for the purpose of the website, but for the index it doesn't need to be kept in the document.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 29, 2017, 1:40pm UTC](https://discuss.elastic.co/t/how-can-i-strip-text-from-a-document-before-it-goes-into-the-index/109589/4 "2017-11-29T13:40:21Z")

</div>

I wonder if Apache Tika (and Ingest Attachment plugin) would automatically remove that content or not. I don't believe so though.

Anyway, to keep the source intact, you can do that with a regex: [https://www.elastic.co/guide/en/elasticsearch/reference/6.0/analysis-pattern\_replace-tokenfilter.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/analysis-pattern_replace-tokenfilter.html)

---

<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:** [December 27, 2017, 1:40pm UTC](https://discuss.elastic.co/t/how-can-i-strip-text-from-a-document-before-it-goes-into-the-index/109589/5 "2017-12-27T13:40:25Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
