title: Elasticsearch scan and scroll - add to new index
body: <p>Elasticsearch and command line programming noobie question.</p>
  
  <p>I have elasticsearch set up locally  on my computer and want to pull documents from a server that uses a different version of es using the scan and scroll api and add them into my index. I am having trouble figuring out how to do this with the bulk api for es. </p>
  
  <p>Right now in my testing phase I am just pulling a few documents from the server using the following code (which works):</p>
  
  <pre><code>   http MY-OLD-ES.com:9200/INDEX/TYPE/_search?size=1000 | jq   .hits.hits[] -c | while read x; do id="`echo "$x" | jq -r ._id`"; index="`echo "$x" | jq -r ._index`"; type="`echo "$x" | jq -r ._type`"; doc="`echo "$x" | jq ._source`"; http put "localhost:9200/junk-$index/$type/$id" &lt;&lt;&lt;"$doc"; done
  </code></pre>
  
  <p>Any tips on how scan and scroll works (noob and a bit confused). So far know I can scroll and get a scroll id, but I'm unclear what to do with the scroll id.
  If I call </p>
  
  <pre><code>http get http://MY-OLD-ES.com:9200/my_index/_search?scroll=1m&amp;search_type=scan&amp;size=10
  </code></pre>
  
  <p>I'll receive a scroll id. Can this be piped in and parsed the same way? Additionally, I believe I'll need a while loop to tell it to keep requesting. How exactly should I go about this? </p>
  
  <p>Thanks!</p>