# Change document data while reindexing documents

**URL:** https://discuss.elastic.co/t/change-document-data-while-reindexing-documents/222063
**Category:** Elasticsearch
**Created:** [March 4, 2020, 11:30am UTC](https://discuss.elastic.co/t/change-document-data-while-reindexing-documents/222063 "2020-03-04T11:30:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Bengagi\_Foued](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bengagi_foued/32/61961_2.png) [@Bengagi\_Foued](https://discuss.elastic.co/u/Bengagi_Foued)
#### Post date: [March 4, 2020, 11:30am UTC](https://discuss.elastic.co/t/change-document-data-while-reindexing-documents/222063/1 "2020-03-04T11:30:07Z")

</div>

i'd like to know if there is a way to ignore some fields that contains specifics values while reindexing

---

<div class="post-metadata">

### Author: ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)
#### Post date: [March 4, 2020, 11:38am UTC](https://discuss.elastic.co/t/change-document-data-while-reindexing-documents/222063/2 "2020-03-04T11:38:52Z")

</div>

Hi,

In other words you want to remove fields in the target index which are in the source index? While I haven't tried it out I guess this is what you want:

> ```
> POST _reindex
> {
> "source": {
> "index": "twitter",
> "_source": ["user", "_doc"]
> },
> "dest": {
> "index": "new_twitter"
> }
> }
> 
> ```

> **[Reindex API | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-filter-source)**

> `_source`  
> (Optional, string) If `true` reindexes all source fields. Set to a list to reindex select fields. Defaults to `true` .

Best regards  
Wolfram

---

<div class="post-metadata">

### Author: ![Bengagi\_Foued](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bengagi_foued/32/61961_2.png) [@Bengagi\_Foued](https://discuss.elastic.co/u/Bengagi_Foued)
#### Post date: [March 4, 2020, 12:13pm UTC](https://discuss.elastic.co/t/change-document-data-while-reindexing-documents/222063/3 "2020-03-04T12:13:31Z")

</div>

Hi ,  
i want to ignore fields based on their value , for example if date field has a specific value in the source index i'd like to put a new value for the date in the target index

---

<div class="post-metadata">

### Author: ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)
#### Post date: [March 4, 2020, 12:22pm UTC](https://discuss.elastic.co/t/change-document-data-while-reindexing-documents/222063/4 "2020-03-04T12:22:40Z")

</div>

Hi,

If you want to do that based on the value this is not the correct way for you. Instead, you can use a script to modify the documents before writing them to the new index:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#reindex-scripts](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#reindex-scripts)

Best regards  
Wolfram

---

<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: [April 1, 2020, 12:22pm UTC](https://discuss.elastic.co/t/change-document-data-while-reindexing-documents/222063/5 "2020-04-01T12:22:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
