# Mapping; extract substring from URL as its own field

**URL:** <https://discuss.elastic.co/t/mapping-extract-substring-from-url-as-its-own-field/217128>\
**Category:** Elasticsearch\
**Created:** [January 30, 2020, 8:39am UTC](https://discuss.elastic.co/t/mapping-extract-substring-from-url-as-its-own-field/217128 "2020-01-30T08:39:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tobias\_Eriksson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tobias_eriksson/32/61713_2.png) [@Tobias\_Eriksson](https://discuss.elastic.co/u/Tobias_Eriksson)\
**Post date:** [January 30, 2020, 8:39am UTC](https://discuss.elastic.co/t/mapping-extract-substring-from-url-as-its-own-field/217128/1 "2020-01-30T08:39:04Z")

</div>

Out logging contains all URLs that comes in to our server  
Now in the full URL is in the "message" field  
e.g.  
"[http://server/api/orders?filter=(EQ%20reference-number%20"5c631c69-e06f-411b-8a21-d1bb37958071")&include=order-items.order-product](http://server/api/orders?filter=(EQ%20reference-number%20%225c631c69-e06f-411b-8a21-d1bb37958071%22)&include=order-items.order-product)

I would like to extract "orders" from "[http://server/api/](http://server/api/) **orders**?"  
This way I will be able to easily group by this when I do aggregation which would otherwise not be possible

Can this be done with elastic mapping ?  
or does this have to happen before the mapping ?

-Tobias

---

<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:** [January 30, 2020, 2:29pm UTC](https://discuss.elastic.co/t/mapping-extract-substring-from-url-as-its-own-field/217128/2 "2020-01-30T14:29:09Z")

</div>

you may want to check out the ingest node in combination with the dissect processor

```auto
POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "dissect": {
          "field": "input",
          "pattern": "%{url}?%{param_string}"
        }
      }
    ]
  },
  "docs": [
    {"_source" : { "input" : "https://example.org?foo=bar&spam=eggs" } }
  ]
}

```

---

<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:** [February 27, 2020, 2:29pm UTC](https://discuss.elastic.co/t/mapping-extract-substring-from-url-as-its-own-field/217128/3 "2020-02-27T14:29:17Z")

</div>

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