# \[Reindex in Java API\] how to reindex subset of fields

**URL:** <https://discuss.elastic.co/t/reindex-in-java-api-how-to-reindex-subset-of-fields/176991>\
**Category:** Elasticsearch\
**Created:** [April 16, 2019, 3:45am UTC](https://discuss.elastic.co/t/reindex-in-java-api-how-to-reindex-subset-of-fields/176991 "2019-04-16T03:45:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amCharlie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amcharlie/32/44211_2.png) [@amCharlie](https://discuss.elastic.co/u/amCharlie)\
**Post date:** [April 16, 2019, 3:45am UTC](https://discuss.elastic.co/t/reindex-in-java-api-how-to-reindex-subset-of-fields/176991/1 "2019-04-16T03:45:50Z")

</div>

In Rest API, there's a function to reindex only a subset of the fields from the original documents by using `source`  
POST \_reindex  
{  
"source": {  
"index": "twitter",  
"\_source": ["user", "\_doc"]  
},  
"dest": {  
"index": "new\_twitter"  
}  
}

**How can I do this by Java API?**  
references:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)  
[https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-document-reindex.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-document-reindex.html)

---

<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:** [May 14, 2019, 3:45am UTC](https://discuss.elastic.co/t/reindex-in-java-api-how-to-reindex-subset-of-fields/176991/2 "2019-05-14T03:45:52Z")

</div>

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