# Changing response from update from a script

**URL:** <https://discuss.elastic.co/t/changing-response-from-update-from-a-script/19682>\
**Category:** Elasticsearch\
**Created:** [September 9, 2014, 1:49pm UTC](https://discuss.elastic.co/t/changing-response-from-update-from-a-script/19682 "2014-09-09T13:49:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jennifer\_Cumming](https://avatars.discourse-cdn.com/v4/letter/j/cab0a1/32.png) [@Jennifer\_Cumming](https://discuss.elastic.co/u/Jennifer_Cumming)\
**Post date:** [September 9, 2014, 1:49pm UTC](https://discuss.elastic.co/t/changing-response-from-update-from-a-script/19682/1 "2014-09-09T13:49:46Z")

</div>

I have an update script that updates the contents of a nested object array  
and it works fine when everything is fine but sometimes we want to be able  
to reject an update due to invalid parameters (such as a missing mandatory  
field) and return an error.

I can set the ctx.op to none so that the \_version isn't changed but that  
only really works if the version is known before the request is made. So is  
there something in ctx that can be changed so that an error response is  
returned?

Code would be something like this:

if (myparam.mandatory == null)  
{  
ctx.op = "none"  
// more here to return an error response  
}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/fffca062-a2d6-441c-97c8-139d7bbabca5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fffca062-a2d6-441c-97c8-139d7bbabca5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [September 24, 2014, 8:26am UTC](https://discuss.elastic.co/t/changing-response-from-update-from-a-script/19682/2 "2014-09-24T08:26:00Z")

</div>

Hello Jennifer ,

I couldn't find any feature for this.  
I feel this is a valid use case and i will file a bug on the same.

Thanks  
Vineeth

On Tue, Sep 9, 2014 at 7:19 PM, Jennifer Cumming [addedsparkle@gmail.com](mailto:addedsparkle@gmail.com)  
wrote:

> I have an update script that updates the contents of a nested object array  
> and it works fine when everything is fine but sometimes we want to be able  
> to reject an update due to invalid parameters (such as a missing mandatory  
> field) and return an error.
> 
> I can set the ctx.op to none so that the \_version isn't changed but that  
> only really works if the version is known before the request is made. So is  
> there something in ctx that can be changed so that an error response is  
> returned?
> 
> Code would be something like this:
> 
> if (myparam.mandatory == null)  
> {  
> ctx.op = "none"  
> // more here to return an error response  
> }
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/fffca062-a2d6-441c-97c8-139d7bbabca5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fffca062-a2d6-441c-97c8-139d7bbabca5%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/fffca062-a2d6-441c-97c8-139d7bbabca5%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/fffca062-a2d6-441c-97c8-139d7bbabca5%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3Dv6uyA3UUwBDjRAMYTa49-Rvtke0mxfKmXy3SwSnMUjw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3Dv6uyA3UUwBDjRAMYTa49-Rvtke0mxfKmXy3SwSnMUjw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:00am UTC](https://discuss.elastic.co/t/changing-response-from-update-from-a-script/19682/3 "2017-07-06T01:00:18Z")

</div>


