# ES index automatic mapping update

**URL:** <https://discuss.elastic.co/t/es-index-automatic-mapping-update/242078>\
**Category:** Elasticsearch\
**Created:** [July 21, 2020, 5:32pm UTC](https://discuss.elastic.co/t/es-index-automatic-mapping-update/242078 "2020-07-21T17:32:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antonio\_Antovski](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/antonio_antovski/32/65944_2.png) [@Antonio\_Antovski](https://discuss.elastic.co/u/Antonio_Antovski)\
**Post date:** [July 21, 2020, 5:32pm UTC](https://discuss.elastic.co/t/es-index-automatic-mapping-update/242078/1 "2020-07-21T17:32:54Z")

</div>

I have a Python script that synchronizes the data between a relational database and ElasticSearch, i.e. on every new insert into the relational database, the data is being inserted into the ES index too. But, whenever I create a new column or a table in the relational database, I manually update the mapping for the ES index. So, I was wondering if there is a way for this to be automated? Whenever I create a new table in the relational database, I'd like a new, let's say, nested field to be created in the ES index, and for each new column in the relational database, a new field to be added in the ES index mapping.  
Any ideas and suggestions on how to do this are appreciated.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 22, 2020, 11:34pm UTC](https://discuss.elastic.co/t/es-index-automatic-mapping-update/242078/2 "2020-07-22T23:34:36Z")

</div>

The only way to handle that would be to build more code, there's nothing native to Elasticsearch that can be leveraged here sorry to say.

---

<div class="post-metadata">

**Author:** ![Vinayak\_Sapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinayak_sapre/32/45939_2.png) [@Vinayak\_Sapre](https://discuss.elastic.co/u/Vinayak_Sapre)\
**Post date:** [July 23, 2020, 3:56am UTC](https://discuss.elastic.co/t/es-index-automatic-mapping-update/242078/3 "2020-07-23T03:56:21Z")

</div>

@Antonio_Antovski

> [@Antonio\_Antovski](#):
>
> I create a new table in the relational database, I'd like a new, let's say, nested field to be created in the ES index,

In rough comparison SQL table maps to an index and SQL table column maps to a field in Elasticsearch.

Whenever you post a document to an index, Elasticsearch's default behavior will create a new index if it does not exist. If you define index templates you can control settings/mappings of the new index. Upfront index creation is not mandatory. [Index API | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-creation)

Similarly Elasticsearch will update index mapping whenever it sees a new field in the document. The data type is determined by value. You can control it by defining dynamic templates. In short upfront field definition is not mandatory either. [Dynamic mapping | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-mapping.html)

---

<div class="post-metadata">

**Author:** ![Antonio\_Antovski](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/antonio_antovski/32/65944_2.png) [@Antonio\_Antovski](https://discuss.elastic.co/u/Antonio_Antovski)\
**Post date:** [July 23, 2020, 9:56am UTC](https://discuss.elastic.co/t/es-index-automatic-mapping-update/242078/4 "2020-07-23T09:56:58Z")

</div>

@Vinayak_Sapre Thank you for the answer. But, in this way 'nested' type fields won't be created, which I'll need further for better and easier querying the index. Or, am I wrong?

---

<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:** [August 20, 2020, 9:57am UTC](https://discuss.elastic.co/t/es-index-automatic-mapping-update/242078/5 "2020-08-20T09:57:08Z")

</div>

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