# Rename nested fields with spaces using Ingest and Reindex

**URL:** <https://discuss.elastic.co/t/rename-nested-fields-with-spaces-using-ingest-and-reindex/234984>\
**Category:** Elasticsearch\
**Created:** [May 29, 2020, 8:40pm UTC](https://discuss.elastic.co/t/rename-nested-fields-with-spaces-using-ingest-and-reindex/234984 "2020-05-29T20:40:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![matheusMoreno](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matheusmoreno/32/69401_2.png) [@matheusMoreno](https://discuss.elastic.co/u/matheusMoreno)\
**Post date:** [May 29, 2020, 8:40pm UTC](https://discuss.elastic.co/t/rename-nested-fields-with-spaces-using-ingest-and-reindex/234984/1 "2020-05-29T20:40:21Z")

</div>

**UPDATE:** I'm more stumped than before because I was able to update some fields with spaces, and not others. As a concrete example, `intervention_time.operation.H OURS` gets updated to `intervention_time.operation.hours` just fine, but `N. of Instance` doesn't get updated to `N. of Instances`. What could be happening here?

Hi, everyone!

I have a very messy index that I want to organize to have the same fields across all documents. For instance, I have documents with a field called "`Date`" and others with "`1 Date`", because the fields are being created automatically using a script that parses through text files.

I wrote a script that sees what fields can be merged and creates an Ingest node with some `rename`s, and then the documents are re-indexed with Reindex and the Ingest node created. This works fine for simple fields or fields without spaces, but when I try something like

```auto
    {
        "rename": {
            "field": "exampleField.bad name",
            "target_field": "exampleField.goodName"
        }
    }

```

I receive the following error:

```auto
      "failures" : [
        {
          "index" : "newIndex",
          "type" : "_doc",
          "id" : "123",
          "cause" : {
            "type" : "illegal_argument_exception",
            "reason" : "field [exampleField.bad name] doesn't exist"
          },
          "status" : 400
        }

```

I noticed that this happens with nested fields containing spaces (nested fields without spaces and fields with spaces but without the dot separator work fine). I tried escaping the spaces, using `'field name'` and `\"field name\"`, and considered using a script, but nothing worked. I'm completely stumped. I know that putting spaces on fields isn't ideal, but I already have this index and I want to organize it. What can I do?

P.S.: Since I don't know if the proposed solution will work for my other problem, I might as well mention it. Similarly, I have some nested fields in arrays, such as

```auto
    {"myField": [
      {"field 1": "value1",
       "field 2": "value2"},
      {"field 1": "value3",
       "field 2": "value4"}
    ]}

```

I was renaming these fields with a `foreach`, and it was working fine, but the same problem occurred: the Ingest can't access fields with spaces. In this case, I was inserting `"_ingest._value.field 1"` in the `field` option, and was receiving the same error.

---

<div class="post-metadata">

**Author:** ![matheusMoreno](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matheusmoreno/32/69401_2.png) [@matheusMoreno](https://discuss.elastic.co/u/matheusMoreno)\
**Post date:** [June 3, 2020, 8:58pm UTC](https://discuss.elastic.co/t/rename-nested-fields-with-spaces-using-ingest-and-reindex/234984/2 "2020-06-03T20:58:58Z")

</div>

After some more research, I solved my problem by using the [dot expander processor](https://www.elastic.co/guide/en/elasticsearch/reference/current/dot-expand-processor.html) with the problematic fields. That solved everything!

---

<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:** [July 1, 2020, 8:59pm UTC](https://discuss.elastic.co/t/rename-nested-fields-with-spaces-using-ingest-and-reindex/234984/3 "2020-07-01T20:59:04Z")

</div>

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