# Remapping an index

**URL:** <https://discuss.elastic.co/t/remapping-an-index/262400>\
**Category:** Elasticsearch\
**Created:** [January 27, 2021, 5:18pm UTC](https://discuss.elastic.co/t/remapping-an-index/262400 "2021-01-27T17:18:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidoffX](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DavidoffX](https://discuss.elastic.co/u/DavidoffX)\
**Post date:** [January 27, 2021, 5:18pm UTC](https://discuss.elastic.co/t/remapping-an-index/262400/1 "2021-01-27T17:18:18Z")

</div>

I've followed is guide in an attempt to apply a new (reduced) mapping to an existing index :

> **[Changing Mapping with Zero Downtime](https://www.elastic.co/blog/changing-mapping-with-zero-downtime)**

I realise that this is a very old blog post. The "atomic" step which is said to re-index , doesn't seem to index any documents.

I've tried creating a new index with the reduced mappings and using the \_reindex endpoint to copy over documents, but this seems to overwrite the mapping that I have added to the new index with the mappings from the original index.

Am I missing something (obvious)?

---

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [January 27, 2021, 7:05pm UTC](https://discuss.elastic.co/t/remapping-an-index/262400/2 "2021-01-27T19:05:57Z")

</div>

Yea, you are correct in using \_reindex API as that is required to reindex documents from old to new index. However, if your new index has reduced mapping, in other words, fields "missing", mapping for missing fields is added automatically as default.  
To get around this, you may choose to selectively reindex fields. Check this out ... [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-filter-source](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-filter-source)

As an example ... the following worked for me ...

```auto
PUT test_firstname_lastname
{
  "mappings" : {
    "document" : {
      "properties" : {
        "first" : {
            "type" : "text"
          },
        "last" : {
            "type" : "text"
          }
      }
    }
}
}

PUT test_firstname_lastname/document/1
{
  "first":"John",
  "last":"Doe"
}

GET test_firstname_lastname/_search

PUT test_firstname
{
  "mappings" : {
    "document" : {
      "properties" : {
        "first" : {
            "type" : "text"
          }
      }
    }
}
}

POST _reindex
{
  "source": {
    "index": "test_firstname_lastname",
    "_source": ["first"]
  },
  "dest": {
    "index": "test_firstname"
  }
}

GET test_firstname/_mapping
GET test_firstname/_search

```

---

<div class="post-metadata">

**Author:** ![DavidoffX](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DavidoffX](https://discuss.elastic.co/u/DavidoffX)\
**Post date:** [January 31, 2021, 7:38pm UTC](https://discuss.elastic.co/t/remapping-an-index/262400/3 "2021-01-31T19:38:43Z")

</div>

Thanks for the answer Jaspreeet.

Turned out that this as me misunderstanding elasticsearch basics. I was confusing the \_source property of a doc with the mapping of an index.

> [@Dynamic mapping setting not honoured](https://discuss.elastic.co/t/dynamic-mapping-setting-not-honoured/262551):
>
> If I create new index with a mapping definition eg. { "mappings": { "dynamic": "false", "properties": { ...} } } and then send data to it with fields that aren't included in the mapping, they are still created dynamically. If I set dynaminc to "strict" then the data sent is dropped. Having dynamic as false seems to give identical behaviour to having it as true, or undefined. Am I missing something? This is with elasticsearch v 7.10.1

---

<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 28, 2021, 7:38pm UTC](https://discuss.elastic.co/t/remapping-an-index/262400/4 "2021-02-28T19:38:58Z")

</div>

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