# Nested Document - Created with null

**URL:** <https://discuss.elastic.co/t/nested-document-created-with-null/27153>\
**Category:** Elasticsearch\
**Created:** [August 10, 2015, 8:15pm UTC](https://discuss.elastic.co/t/nested-document-created-with-null/27153 "2015-08-10T20:15:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdb70](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jdb70](https://discuss.elastic.co/u/jdb70)\
**Post date:** [August 10, 2015, 8:15pm UTC](https://discuss.elastic.co/t/nested-document-created-with-null/27153/1 "2015-08-10T20:15:26Z")

</div>

Hello,  
I have a nested document and I am using scripted upsert to add nested document. The first entry in the nested document is always an 'null' string value. My input to ES is '{"script\_file": "update-messages","scripted\_upsert":true,"params":{[some values]},"upsert" : {}}'. The first entry is always a string valued as 'null' and then data is added. So if the first entry into nested document is 'testing with ES', I see 'nulltesting with ES' in ElasticSearch. Any idea what could be causing the nested document to be initialized with a 'null' string?

Thanks in advance for your help.

---

<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:** [August 11, 2015, 10:48am UTC](https://discuss.elastic.co/t/nested-document-created-with-null/27153/2 "2015-08-11T10:48:18Z")

</div>

Can you post the code so we can replicate and see more detail?

---

<div class="post-metadata">

**Author:** ![jdb70](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jdb70](https://discuss.elastic.co/u/jdb70)\
**Post date:** [August 11, 2015, 3:28pm UTC](https://discuss.elastic.co/t/nested-document-created-with-null/27153/3 "2015-08-11T15:28:39Z")

</div>

Hello,  
I was able to get this to work by removing the scripted\_upsert and by providing the default within upsert:{} parameter. Thanks for taking a look.

---

<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 5, 2017, 11:56pm UTC](https://discuss.elastic.co/t/nested-document-created-with-null/27153/4 "2017-07-05T23:56:27Z")

</div>


