# Reindex part of Elasticsearch index onto new index

**URL:** <https://discuss.elastic.co/t/reindex-part-of-elasticsearch-index-onto-new-index/139076>\
**Category:** Elasticsearch\
**Created:** [July 9, 2018, 3:19am UTC](https://discuss.elastic.co/t/reindex-part-of-elasticsearch-index-onto-new-index/139076 "2018-07-09T03:19:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bps](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@bps](https://discuss.elastic.co/u/bps)\
**Post date:** [July 9, 2018, 3:19am UTC](https://discuss.elastic.co/t/reindex-part-of-elasticsearch-index-onto-new-index/139076/1 "2018-07-09T03:19:59Z")

</div>

I have a test ElasticSearch 6.0 index populated with millions of records, likely to be in the billions in production. I need to search for a subset of these records, then save this subset of the original set into a secondary index for later searching. I have proven this out via querying ES on Kibana, the challenge is to find appropriate APIs in Java 8 using my Jest client ([searchbox.io](http://searchbox.io), version 5.3.3) to do the same. . How can this be accomplished in Java? It seems that the current APIs do not support what I am proposing to do and I have hit a dead-end using the HttpUrlConnection class... Below is a partial snippet of what works in Kibana. Any help or guidance is very much appreciated.

POST \_reindex?slices=10&wait\_for\_completion=false  
{  
"conflicts":"proceed",  
"source":{  
"index":"source\_idx",  
"size":5000,  
"query":{  
"bool":{  
"filter":{  
"bool":{  
"must":[  
{  
"nested":{  
"path":"foo",  
"query":{  
"bool":{  
"must":[  
{ ...  
}  
}  
},  
"dest":{  
"index":"my\_dest\_idx"  
},  
"script" :  
{  
"id": "my\_saved\_painless\_script",  
"params" :  
{ ...  
}  
}

---

<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:** [August 6, 2018, 3:22am UTC](https://discuss.elastic.co/t/reindex-part-of-elasticsearch-index-onto-new-index/139076/2 "2018-08-06T03:22:19Z")

</div>

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