Help with reindex() function

Hi Elastic team,

I'm trying to make a Python reindexing script using the Elasticsearch library, but I'm not sure how reindex() function should be used.
The script would be executed by typing: python auto_reindex YYYY.MM.DD, as you see, expecting date, because my indices are called xxxxxxx-YYY.MM.DD.

This is how I created the Elasticsearch object: es = Elasticsearch({"host": "localhost", "port": 9200}). My Elasticserach is running at port 9200.

I'm getting an error at the following line:

es.reindex(body='{"source":{"index":"original-index-{0}"},"dest":{"index":"temporary-index-{0}"}}'.format(date))

The error I'm getting is:

Traceback (most recent call last):
File "auto_reindex_test", line 20, in
es.reindex(body='{"source":{"index":"original-index-{0}"},"dest":{"index":"temporary-index-{0}"}}'.format(date))
KeyError: '"source"'

I'm sure I'm doing something wrong but I don't know what it is. Could someone tell me how should I properly create my Elasticsearch object if I'm doing it wrong, or how to use the function reindex() to reindex the index xxxxxx-YY.MM.DD into xxxxxx-tmp-YY.MM.DD?

Some help would be really appreciated.

Best regards,
Sergio.

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