# Using KV processors when field names have space

**URL:** https://discuss.elastic.co/t/using-kv-processors-when-field-names-have-space/244631
**Category:** Elasticsearch
**Created:** [August 11, 2020, 9:24pm UTC](https://discuss.elastic.co/t/using-kv-processors-when-field-names-have-space/244631 "2020-08-11T21:24:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![BkQc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bkqc/32/73699_2.png) [@BkQc](https://discuss.elastic.co/u/BkQc)
#### Post date: [August 11, 2020, 9:24pm UTC](https://discuss.elastic.co/t/using-kv-processors-when-field-names-have-space/244631/1 "2020-08-11T21:24:48Z")

</div>

Hello,  
I'm trying to parse a log in which elements are separated by ; and keys/values by =.  
My problem is that some keys have spaces in their name.  
Though KV will process it correctly, having spaces in name causes lot of problem in the end (for query and grok multisourcing for instance).

What I would like is to replace the space in the name with \_ or - but I can't find anything in the documentation.

A row of data coule look something like

```auto
MVC Controller=Home;MVC Action=Index

```

The keys are variable.

The end problem is related to [this other post](https://discuss.elastic.co/t/discover-field-names-with-spaces/37467/5) in which @Joe\_Flemming, elastic team member, says they didn't think space in names were even possible.

Any suggestion even if OOB would be appreciated.

---

<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: [August 12, 2020, 9:02am UTC](https://discuss.elastic.co/t/using-kv-processors-when-field-names-have-space/244631/2 "2020-08-12T09:02:09Z")

</div>

How about this (assuming you are using an ingest pipeline, which you did not specifically mention).

```auto
POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "kv": {
          "field": "input",
          "target_field": "output",
          "field_split": ";",
          "value_split": "="
        }
      },
      {
        "script": {
          "lang": "painless",
          "source": "def data = ctx.output ; ctx.output = [:] ; data.forEach((k, v) -> ctx.output[k.replace(' ', '_')] = v);"
        }
      }
    ]
  },
  "docs": [
    {
      "_source": {
        "input": "MVC Controller=Home;MVC Action=Index"
      }
    }
  ]
}

```

---

<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: [September 9, 2020, 9:02am UTC](https://discuss.elastic.co/t/using-kv-processors-when-field-names-have-space/244631/3 "2020-09-09T09:02:21Z")

</div>

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