# How to use html\_strip in an attachment pipeline?

**URL:** <https://discuss.elastic.co/t/how-to-use-html-strip-in-an-attachment-pipeline/224096>\
**Category:** Elasticsearch\
**Created:** [March 18, 2020, 11:56am UTC](https://discuss.elastic.co/t/how-to-use-html-strip-in-an-attachment-pipeline/224096 "2020-03-18T11:56:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![photocurio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/photocurio/32/62986_2.png) [@photocurio](https://discuss.elastic.co/u/photocurio)\
**Post date:** [March 18, 2020, 11:56am UTC](https://discuss.elastic.co/t/how-to-use-html-strip-in-an-attachment-pipeline/224096/1 "2020-03-18T11:56:57Z")

</div>

I am indexing documents with Elasticsearch, and its working well. My problem is that some documents have hyperlinks in them. Search is finding terms in these links, which I don't want.

I tried to add a html\_strip processor to the pipeline to remove the links on ingest, like this:

```auto
PIPELINE = {
    "description": "Extract attachment information"
    "processors": {
        "foreach": {
            "field": "attachments",
            "processor": {
                "attachment": {
                    "target_field": "_ingest._value.attachment",
                    "field": "_ingest._value.data",
                    "ignore_missing": 1,
                    "indexed_chars": -1,
                    "ignore_failure": 1
                }
            }
        }
    },
    {
        "foreach": {
            "field": "attachments",
            "processor": {
                "remove": {
                    "field": "_ingest._value.data"
                }
            }
        }
    },
    {
        "foreach": {
            "field": "attachments",
            "processor": {
                "html_strip": {
                    "field": "_ingest._value.attachment"
                }
            }
        }
    }
}

```

This does not work. I re-send the mapping, and re-index the attachments, but I still find hits inside hyperlinks in documents. Got any tips?

---

<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:** [March 18, 2020, 2:51pm UTC](https://discuss.elastic.co/t/how-to-use-html-strip-in-an-attachment-pipeline/224096/2 "2020-03-18T14:51:54Z")

</div>

Hey,

please provide a **fully reproducible but minimal example**. I have created a snippet that works for me, but that won't help you or me 🙂

```auto
POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "foreach": {
          "field": "attachments",
          "processor": {
            "html_strip": {
              "field": "_ingest._value.attachment"
            }
          }
        }
      }
    ]
  },
  "docs": [
    {
      "_source": {
        "attachments": [
          {
            "attachment": "This is <b>a test</b>"
          }
        ]
      }
    }
  ]
}

```

Maybe the structure of your documents is different?

--Alex

---

<div class="post-metadata">

**Author:** ![photocurio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/photocurio/32/62986_2.png) [@photocurio](https://discuss.elastic.co/u/photocurio)\
**Post date:** [March 18, 2020, 11:29pm UTC](https://discuss.elastic.co/t/how-to-use-html-strip-in-an-attachment-pipeline/224096/3 "2020-03-18T23:29:38Z")

</div>

Thanks Alex, good point. I'll test this way.

---

<div class="post-metadata">

**Author:** ![photocurio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/photocurio/32/62986_2.png) [@photocurio](https://discuss.elastic.co/u/photocurio)\
**Post date:** [March 20, 2020, 9:06pm UTC](https://discuss.elastic.co/t/how-to-use-html-strip-in-an-attachment-pipeline/224096/4 "2020-03-20T21:06:29Z")

</div>

I found the issue. I'm using Elasticsearch 6.4. It looks like there is no _html\_strip_ processor in this version.

---

<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:** [April 17, 2020, 9:06pm UTC](https://discuss.elastic.co/t/how-to-use-html-strip-in-an-attachment-pipeline/224096/5 "2020-04-17T21:06:40Z")

</div>

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