# Search and replace in all my documents

**URL:** <https://discuss.elastic.co/t/search-and-replace-in-all-my-documents/32449>\
**Category:** Elasticsearch\
**Created:** [October 18, 2015, 7:39pm UTC](https://discuss.elastic.co/t/search-and-replace-in-all-my-documents/32449 "2015-10-18T19:39:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DocMAX](https://avatars.discourse-cdn.com/v4/letter/d/6bbea6/32.png) [@DocMAX](https://discuss.elastic.co/u/DocMAX)\
**Post date:** [October 18, 2015, 7:39pm UTC](https://discuss.elastic.co/t/search-and-replace-in-all-my-documents/32449/1 "2015-10-18T19:39:21Z")

</div>

hi,

i want to replace an ip with a hostname.  
how can i do this in all my documents with a particual field "hostname"?  
i prefer to use head plugin and get the code from you.

any help is greatly appreciated,  
docmax

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [October 19, 2015, 1:56am UTC](https://discuss.elastic.co/t/search-and-replace-in-all-my-documents/32449/2 "2015-10-19T01:56:08Z")

</div>

You can't currently [update by a query condition](https://www.elastic.co/guide/en/elasticsearch/reference/1.4/_updating_documents.html). IE You can't currently "UPDATE WHERE" to compare to SQL

Instead, what I tend to do is search for the condition, and use the [scan and scroll](https://www.elastic.co/guide/en/elasticsearch/guide/current/scan-scroll.html) API then a [bulk update](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html#bulk-update). This is usually fine with a relatively static index. If your documents change between reading and updating you could experience conflicts. You'll have to figure out if this is a problem for your use case.

---

<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:44pm UTC](https://discuss.elastic.co/t/search-and-replace-in-all-my-documents/32449/3 "2017-07-05T23:44:09Z")

</div>


