Elasticsearch and command line programming noobie question.
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.
Right now in my testing phase I am just pulling a few documents from the server using the following code (which works):
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" <<<"$doc"; done
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
http get http://MY-OLD-ES.com:9200/my_index/_search?scroll=1m&search_type=scan&size=10
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?
Thanks!