Last active
April 6, 2017 13:19
-
-
Save xamox/b9cd23d3834a03a1089af41dbf1ed6e6 to your computer and use it in GitHub Desktop.
Used to reindex elasticsearch (ELK) setup for changing indexs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import elasticsearch | |
import elasticsearch.helpers | |
elasticSource = elasticsearch.Elasticsearch([{"host": "localhost", "port": 9200}]) | |
elasticDestination = elasticsearch.Elasticsearch([{"host": "localhost", "port": 9200}]) | |
# Setup source and destinations connection to Elasticsearch. Could have been different clusters | |
# Delete index so we know it doesn't exist. | |
elasticDestination.indices.delete(index="index_destination", ignore=[400, 404]) | |
# Create index with nothing in it. | |
elasticDestination.indices.create(index="index_source", ignore=[400, 404]) | |
elasticsearch.helpers.reindex(client=elasticSource, source_index="index_source", target_index="index_destination", target_client=elasticDestination) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment