Skip to content

Instantly share code, notes, and snippets.

@Nick011
Created October 20, 2018 02:04
Show Gist options
  • Save Nick011/17870a853d593a75b8ac67b034d012e7 to your computer and use it in GitHub Desktop.
Save Nick011/17870a853d593a75b8ac67b034d012e7 to your computer and use it in GitHub Desktop.
import requests
res = requests.get('http://localhost:9201/_cat/indices?format=json')
src_indices = res.json()
src_indices = [item['index'] for item in src_indices if not 'monitoring' in item['index']]
body = {
'source': {
'remote': {
'host': 'http://docker.for.mac.localhost:9201'
},
'index': None
},
'dest': {
'index': None
}
}
for index in src_indices:
body['source']['index'] = index
body['dest']['index'] = index
res = requests.post('http://localhost:9200/_reindex', json=body)
print(res.status_code)
print(res.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment