# Add/delete in update api

**URL:** <https://discuss.elastic.co/t/add-delete-in-update-api/7883>\
**Category:** Elasticsearch\
**Created:** [May 28, 2012, 7:35am UTC](https://discuss.elastic.co/t/add-delete-in-update-api/7883 "2012-05-28T07:35:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [May 28, 2012, 7:35am UTC](https://discuss.elastic.co/t/add-delete-in-update-api/7883/1 "2012-05-28T07:35:37Z")

</div>

Hi there,  
I need to know if we can add new attributes and delete the old  
ones in the document?? or this api is just to edit the existing fields??? I  
tried this api to add new one, but not getting the results...so please tell  
me if i am doing something wrong or its not the part of the functionality...

Thanks

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 28, 2012, 7:41am UTC](https://discuss.elastic.co/t/add-delete-in-update-api/7883/2 "2012-05-28T07:41:08Z")

</div>

Just send the new version of your document.

David

Le 28 mai 2012 à 09:35, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in) a écrit :

> Hi there,  
> I need to know if we can add new attributes and delete the old ones in the document?? or this api is just to edit the existing fields??? I tried this api to add new one, but not getting the results...so please tell me if i am doing something wrong or its not the part of the functionality...
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [May 28, 2012, 8:05am UTC](https://discuss.elastic.co/t/add-delete-in-update-api/7883/3 "2012-05-28T08:05:19Z")

</div>

I am sending the new version of the document. but still its just not there  
in the document.

On Monday, 28 May 2012 13:11:08 UTC+5:30, David Pilato wrote:

> Just send the new version of your document.
> 
> David
> 
> Le 28 mai 2012 à 09:35, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in) a écrit :
> 
> > Hi there,  
> > I need to know if we can add new attributes and delete the old  
> > ones in the document?? or this api is just to edit the existing fields??? I  
> > tried this api to add new one, but not getting the results...so please tell  
> > me if i am doing something wrong or its not the part of the  
> > functionality...
> > 
> > Thanks

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 28, 2012, 8:08am UTC](https://discuss.elastic.co/t/add-delete-in-update-api/7883/4 "2012-05-28T08:08:54Z")

</div>

Could you gist your issue ?

Le 28 mai 2012 à 10:05, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in) a écrit :

> I am sending the new version of the document. but still its just not there in the document.
> 
> On Monday, 28 May 2012 13:11:08 UTC+5:30, David Pilato wrote:  
> Just send the new version of your document.
> 
> David
> 
> Le 28 mai 2012 à 09:35, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in) a écrit :
> 
> > Hi there,  
> > I need to know if we can add new attributes and delete the old ones in the document?? or this api is just to edit the existing fields??? I tried this api to add new one, but not getting the results...so please tell me if i am doing something wrong or its not the part of the functionality...
> > 
> > Thanks

---

<div class="post-metadata">

**Author:** ![Benjamin\_Deveze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_deveze/32/1577_2.png) [@Benjamin\_Deveze](https://discuss.elastic.co/u/Benjamin_Deveze)\
**Post date:** [May 28, 2012, 4:08pm UTC](https://discuss.elastic.co/t/add-delete-in-update-api/7883/5 "2012-05-28T16:08:49Z")

</div>

You can use the update API to add new field and delete existing  
fields. Basically you have your doc to update in ctx.\_source and you  
can add new fields and delete fields with the supported language of  
your choice. For example in maven ctx.\_source.foobar = 4 will add a  
new foobar field. Hope this help

On Mon, May 28, 2012 at 9:35 AM, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in) wrote:

> Hi there,  
> I need to know if we can add new attributes and delete the old  
> ones in the document?? or this api is just to edit the existing fields??? I  
> tried this api to add new one, but not getting the results...so please tell  
> me if i am doing something wrong or its not the part of the functionality...
> 
> Thanks

--  
Benjamin DEVEZE

---

<div class="post-metadata">

**Author:** ![Benjamin\_Deveze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_deveze/32/1577_2.png) [@Benjamin\_Deveze](https://discuss.elastic.co/u/Benjamin_Deveze)\
**Post date:** [May 28, 2012, 4:09pm UTC](https://discuss.elastic.co/t/add-delete-in-update-api/7883/6 "2012-05-28T16:09:40Z")

</div>

"maven" -\> "mvel"

On Mon, May 28, 2012 at 6:08 PM, Benjamin Devèze  
[benjamin.deveze@gmail.com](mailto:benjamin.deveze@gmail.com) wrote:

> You can use the update API to add new field and delete existing  
> fields. Basically you have your doc to update in ctx.\_source and you  
> can add new fields and delete fields with the supported language of  
> your choice. For example in maven ctx.\_source.foobar = 4 will add a  
> new foobar field. Hope this help
> 
> On Mon, May 28, 2012 at 9:35 AM, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in) wrote:
> 
> > Hi there,  
> > I need to know if we can add new attributes and delete the old  
> > ones in the document?? or this api is just to edit the existing fields??? I  
> > tried this api to add new one, but not getting the results...so please tell  
> > me if i am doing something wrong or its not the part of the functionality...
> > 
> > Thanks
> 
> --  
> Benjamin DEVEZE

--  
Benjamin DEVEZE

---

<div class="post-metadata">

**Author:** ![Benjamin\_Deveze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_deveze/32/1577_2.png) [@Benjamin\_Deveze](https://discuss.elastic.co/u/Benjamin_Deveze)\
**Post date:** [May 28, 2012, 5:17pm UTC](https://discuss.elastic.co/t/add-delete-in-update-api/7883/7 "2012-05-28T17:17:03Z")

</div>

To be complete you can use the following syntax to delete an existing field:

"script" : "ctx.\_source.remove("foobar")"

On Mon, May 28, 2012 at 6:09 PM, Benjamin Devèze  
[benjamin.deveze@gmail.com](mailto:benjamin.deveze@gmail.com) wrote:

> "maven" -\> "mvel"
> 
> On Mon, May 28, 2012 at 6:08 PM, Benjamin Devèze  
> [benjamin.deveze@gmail.com](mailto:benjamin.deveze@gmail.com) wrote:
> 
> > You can use the update API to add new field and delete existing  
> > fields. Basically you have your doc to update in ctx.\_source and you  
> > can add new fields and delete fields with the supported language of  
> > your choice. For example in maven ctx.\_source.foobar = 4 will add a  
> > new foobar field. Hope this help
> > 
> > On Mon, May 28, 2012 at 9:35 AM, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in) wrote:
> > 
> > > Hi there,  
> > > I need to know if we can add new attributes and delete the old  
> > > ones in the document?? or this api is just to edit the existing fields??? I  
> > > tried this api to add new one, but not getting the results...so please tell  
> > > me if i am doing something wrong or its not the part of the functionality...
> > > 
> > > Thanks
> > 
> > --  
> > Benjamin DEVEZE
> 
> --  
> Benjamin DEVEZE

--  
Benjamin DEVEZE

---

<div class="post-metadata">

**Author:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [May 30, 2012, 4:53am UTC](https://discuss.elastic.co/t/add-delete-in-update-api/7883/8 "2012-05-30T04:53:48Z")

</div>

thanks so much for the help...

On Monday, 28 May 2012 22:47:03 UTC+5:30, Benjamin Devèze wrote:

> To be complete you can use the following syntax to delete an existing  
> field:
> 
> "script" : "ctx.\_source.remove("foobar")"
> 
> On Mon, May 28, 2012 at 6:09 PM, Benjamin Devèze  
> [benjamin.deveze@gmail.com](mailto:benjamin.deveze@gmail.com) wrote:
> 
> > "maven" -\> "mvel"
> > 
> > On Mon, May 28, 2012 at 6:08 PM, Benjamin Devèze  
> > [benjamin.deveze@gmail.com](mailto:benjamin.deveze@gmail.com) wrote:
> > 
> > > You can use the update API to add new field and delete existing  
> > > fields. Basically you have your doc to update in ctx.\_source and you  
> > > can add new fields and delete fields with the supported language of  
> > > your choice. For example in maven ctx.\_source.foobar = 4 will add a  
> > > new foobar field. Hope this help
> > > 
> > > On Mon, May 28, 2012 at 9:35 AM, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in)  
> > > wrote:
> > > 
> > > > Hi there,  
> > > > I need to know if we can add new attributes and delete the  
> > > > old  
> > > > ones in the document?? or this api is just to edit the existing  
> > > > fields??? I  
> > > > tried this api to add new one, but not getting the results...so please  
> > > > tell  
> > > > me if i am doing something wrong or its not the part of the  
> > > > functionality...
> > > > 
> > > > Thanks
> > > 
> > > --  
> > > Benjamin DEVEZE
> > 
> > --  
> > Benjamin DEVEZE
> 
> --  
> Benjamin DEVEZE

---

<div class="post-metadata">

**Author:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [June 21, 2012, 11:52am UTC](https://discuss.elastic.co/t/add-delete-in-update-api/7883/9 "2012-06-21T11:52:42Z")

</div>

I need to add an array structure to the document through update api, tried  
to add the array to the document in the same way, but dint added the array  
field to the document. and it genereted the error "\*  
set\_whatsnew\_on\_next\_login\*". can you please tell me how to add this too???

Thanks

On Monday, 28 May 2012 22:47:03 UTC+5:30, Benjamin Devèze wrote:

> To be complete you can use the following syntax to delete an existing  
> field:
> 
> "script" : "ctx.\_source.remove("foobar")"
> 
> On Mon, May 28, 2012 at 6:09 PM, Benjamin Devèze  
> [benjamin.deveze@gmail.com](mailto:benjamin.deveze@gmail.com) wrote:
> 
> > "maven" -\> "mvel"
> > 
> > On Mon, May 28, 2012 at 6:08 PM, Benjamin Devèze  
> > [benjamin.deveze@gmail.com](mailto:benjamin.deveze@gmail.com) wrote:
> > 
> > > You can use the update API to add new field and delete existing  
> > > fields. Basically you have your doc to update in ctx.\_source and you  
> > > can add new fields and delete fields with the supported language of  
> > > your choice. For example in maven ctx.\_source.foobar = 4 will add a  
> > > new foobar field. Hope this help
> > > 
> > > On Mon, May 28, 2012 at 9:35 AM, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in)  
> > > wrote:
> > > 
> > > > Hi there,  
> > > > I need to know if we can add new attributes and delete the  
> > > > old  
> > > > ones in the document?? or this api is just to edit the existing  
> > > > fields??? I  
> > > > tried this api to add new one, but not getting the results...so please  
> > > > tell  
> > > > me if i am doing something wrong or its not the part of the  
> > > > functionality...
> > > > 
> > > > Thanks
> > > 
> > > --  
> > > Benjamin DEVEZE
> > 
> > --  
> > Benjamin DEVEZE
> 
> --  
> Benjamin DEVEZE

---

<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 6, 2017, 3:23am UTC](https://discuss.elastic.co/t/add-delete-in-update-api/7883/10 "2017-07-06T03:23:05Z")

</div>


