# Gsub not replacing pattern on "url.original" field

**URL:** <https://discuss.elastic.co/t/gsub-not-replacing-pattern-on-url-original-field/211736>\
**Category:** Elasticsearch\
**Tags:** ecs-elastic-common-schema\
**Created:** [December 13, 2019, 12:47am UTC](https://discuss.elastic.co/t/gsub-not-replacing-pattern-on-url-original-field/211736 "2019-12-13T00:47:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![blinx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blinx/32/59319_2.png) [@blinx](https://discuss.elastic.co/u/blinx)\
**Post date:** [December 13, 2019, 12:47am UTC](https://discuss.elastic.co/t/gsub-not-replacing-pattern-on-url-original-field/211736/1 "2019-12-13T00:47:06Z")

</div>

Hi,  
I am trying to modify the _filebeat-7.5.0-apache-access-default_ my goal is to remove part of the url.original field using gsub but then when simulating I dont see any change.

So far my procedure was

1. Deleting the current filebeat-7.5.0-apache-access-default in ES.
2. Posting a modified version, the only change is I added a gsub processor in the list:

```auto
{
    "gsub": {
        "field": "url.original",
        "pattern": "\\&r(.*)",
        "replacement": ""
    }
},

```

The idea is to remove everything from and after "&r" e.g. /products?s=soap&r=sometoken  
I simulate it after and the url.original field is unchanged, any ideas? Thank you!!

---

<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 13, 2019, 1:10pm UTC](https://discuss.elastic.co/t/gsub-not-replacing-pattern-on-url-original-field/211736/2 "2019-12-13T13:10:07Z")

</div>

how about using the `dissect` processor to not deal with regexes?

```auto
POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "dissect": {
          "field": "url.original",
          "pattern": "%{original_url}?%{params}"
        }
      }
    ]
  },
  "docs": [
    {
      "_source": {
        "url": {
          "original": "https://example.org/products?s=soap&r=sometoken"
        }
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![blinx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blinx/32/59319_2.png) [@blinx](https://discuss.elastic.co/u/blinx)\
**Post date:** [December 13, 2019, 3:47pm UTC](https://discuss.elastic.co/t/gsub-not-replacing-pattern-on-url-original-field/211736/3 "2019-12-13T15:47:30Z")

</div>

I haven't thought of that! thank you!!

---

<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:** [January 10, 2020, 3:47pm UTC](https://discuss.elastic.co/t/gsub-not-replacing-pattern-on-url-original-field/211736/4 "2020-01-10T15:47:31Z")

</div>

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