# Is it possible to update nested field by query?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-update-nested-field-by-query/23482>\
**Category:** Elasticsearch\
**Created:** [April 30, 2015, 3:19am UTC](https://discuss.elastic.co/t/is-it-possible-to-update-nested-field-by-query/23482 "2015-04-30T03:19:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)\
**Post date:** [April 30, 2015, 3:19am UTC](https://discuss.elastic.co/t/is-it-possible-to-update-nested-field-by-query/23482/1 "2015-04-30T03:19:52Z")

</div>

hi,  
I am using update by query plugin  
([https://github.com/yakaz/elasticsearch-action-updatebyquery/](https://github.com/yakaz/elasticsearch-action-updatebyquery/)) to update  
documents by query.  
In my case, there is nested field in document, the mapping is something  
like this:

```
        "mappings" : {

```

"mytype" : {  
"properties" : {  
"Myfield1" : {  
"type" : "nested",  
"properties" : {  
"field1" : {  
"type" : "string"  
},  
"field2" : {  
"type" : "long"  
}  
}  
},  
"Title" : {  
"type" : "string"  
}  
}  
}  
}

Then I want to update the nested field Myfield1 by query with following  
request:

{  
"query":{  
"match":{"Title":"elasticsearch"}  
},  
"script" : "ctx.\_source.Myfield1 = [{'nestfield1':'foo  
blabla...','nestfield2':100},{'nestfield1':'abc...','nestfield2':200}]"  
}

But unfortunately, it does not work.

Does update by query support nested object?

BTW: any other ways to update document by query? Is the updatebyquery  
plugin the only choice?

--  
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/90a51ad5-ede4-45d1-bbe8-4cbbf219cc75%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/90a51ad5-ede4-45d1-bbe8-4cbbf219cc75%40googlegroups.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, 12:16am UTC](https://discuss.elastic.co/t/is-it-possible-to-update-nested-field-by-query/23482/2 "2017-07-06T00:16:51Z")

</div>


