I am trying to re-index my Elastic search setup, currently looking at the Elastic search documentation and an example using the Python API
I'm a little bit confused as to how this all works though. I was able to obtain the scroll ID from the Python API:
es = Elasticsearch("myhost")
index = "myindex"
query = {"query":{"match_all":{}}}
response = es.search(index= index, doc_type= "my-doc-type", body= query, search_type= "scan", scroll= "10m")
scroll_id = response["_scroll_id"]
Now my question is, what use is this to me? What does knowing the scrolling id even give me? The documentation says to use the "Bulk API" but I have no idea how the scoll_id factors into this, it was a little confusing.
Could anyone give a brief example showing my how to re-index from this point, considering that I've got the scroll_id correctly?
For anyone who runs into this problem, you can use the following API from the Python client to reindex:
https://elasticsearch-py.readthedocs.org/en/master/helpers.html#elasticsearch.helpers.reindex
This would help you avoid having to scroll and search to get all the data and use the bulk API to put data into the new index.
Hi you can use the scroll api to go through all the documents in the most efficient way. Using the scroll_id you can find a session that is stored on the server for your specific scroll request. So you need to provide the scroll_id with each request to obtain more items.
The bulk api is for more efficient indexing documents. When copying and index you need both, but they are not really related.
I do have some java code that might help you to get a better idea about how it works.
here is an example of reindexing to another elasticsearch node using elasticsearch-py:
you can also reindex the result of a query to a different index here is how to do it: