Skip to content

Instantly share code, notes, and snippets.

@markuskont
Created August 21, 2019 12:11
Show Gist options
  • Save markuskont/472bd03db71ab052be0c798ec5466932 to your computer and use it in GitHub Desktop.
Save markuskont/472bd03db71ab052be0c798ec5466932 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from elasticsearch import Elasticsearch, helpers
host = "X.X.X.X"
pattern = "sessions2"
c1 = ["{}:9213".format(host)]
c2 = ["{}:9214".format(host)]
e1 = Elasticsearch(hosts=c1)
e2 = Elasticsearch(hosts=c2)
indices = e1.cat.indices(format="json")
indices = [i["index"] for i in indices if pattern in i["index"]]
indices = sorted(indices)
for i in indices:
print(i)
helpers.reindex(client=e1,
source_index=i,
target_index=i,
target_client=e2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment