title: Reindex part of Elasticsearch index onto new index via Jest
body: <p>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, version 5.3.3) to do the same. The ElasticSearch cluster is on AWS, so using a transport client is out.</p>
  
  <pre><code>POST _reindex?slices=10&amp;wait_for_completion=false
  { "conflicts": "proceed",
    "source":{
      "index": "my_source_idx",
      "size": 5000,
      "query": { "bool": {
        "filter": { "bool" : { "must" : [
          { "nested": { "path": "test", "query": { "bool": { "must":[
             { "terms" : { "test.RowKey": ["abc"]} },
             { "range" : { "test.dates" : { "lte": "2018-01-01", "gte": "2010-08-01"} } },
             { "range" : { "test.DatesCount" : { "gte": 2} } },
             { "script" : { "script" : { "id": "my_painless_script", 
                "params" : {"min_occurs" : 1, "dateField": "test.dates", "RowKey": ["abc"], "fromDate": "2010-08-01", "toDate": "2018-01-01"}}}}
          ]}}}}
        ]}}
      }}
    },
    "dest": {
      "index": "my_dest_idx"
    },
    "script": {
      "source": &lt;My painless script&gt;
    } }
  </code></pre>
  
  <p>I am aware I can perform a search on the source index, then create and bulk load the response records onto the new index, but I want to be able to do this all in one shot, as I do have a painless script to glean off some information that is pertinent to the queries that will search the secondary index. Performance is a concern, as the application will be chaining subsequent queries together using the destination index to query against. Does anyone know how to do accomplish this using Jest?</p>