# Update by query - nested documents

**URL:** <https://discuss.elastic.co/t/update-by-query-nested-documents/57058>\
**Category:** Elasticsearch\
**Created:** [August 2, 2016, 10:45pm UTC](https://discuss.elastic.co/t/update-by-query-nested-documents/57058 "2016-08-02T22:45:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Mixter](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@Jeff\_Mixter](https://discuss.elastic.co/u/Jeff_Mixter)\
**Post date:** [August 2, 2016, 10:45pm UTC](https://discuss.elastic.co/t/update-by-query-nested-documents/57058/1 "2016-08-02T22:45:45Z")

</div>

I have been trying to use the update by query API to find document subject terms and update them:

"subject": [{  
"@value": "Football"  
}, {  
"@value": "Columbus"  
}]

I would like to run a query across the entire index to find the term "Football" and replace, across all documents, with "Football (Ohio State)". I was not able to get any of the update by query to work. I tried this query:

{  
"script": {  
"inline": "ctx.\_source.subject.@value = "football (Ohio State)""  
},  
"query": {  
"term": {  
"subject.@value": "football"  
}  
}  
}

Also, the reason for having the nested "@values" is because those nested objects can also have "@id" values for URIs. It serves as a bridge way for indexing RDF data.

---

<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, 10:30pm UTC](https://discuss.elastic.co/t/update-by-query-nested-documents/57058/2 "2017-07-05T22:30:34Z")

</div>


