Skip to content
Snippets Groups Projects
Commit 7e407efb authored by Alessandro Cerioni's avatar Alessandro Cerioni
Browse files

The source_url parameter is now optional.

parent 7adc99c0
Branches
Tags
No related merge requests found
...@@ -15,7 +15,11 @@ def main(cfg, wait=True): ...@@ -15,7 +15,11 @@ def main(cfg, wait=True):
template['index_patterns'] = [ cfg['reindexer']['destination_index'] ] template['index_patterns'] = [ cfg['reindexer']['destination_index'] ]
if wait: if wait:
es_source = Elasticsearch([cfg['reindexer']['source_url']], timeout=60)
if 'source_url' in cfg['reindexer'].keys():
es_source = Elasticsearch([cfg['reindexer']['source_url']], timeout=60)
else:
es_source = Elasticsearch([cfg['reindexer']['destination_url']], timeout=60)
count = es_source.count(cfg['reindexer']['source_index']).get('count') count = es_source.count(cfg['reindexer']['source_index']).get('count')
...@@ -42,7 +46,7 @@ def main(cfg, wait=True): ...@@ -42,7 +46,7 @@ def main(cfg, wait=True):
body = { "source": { body = { "source": {
"remote": { "host": cfg['reindexer']['source_url'] }, #"remote": { "host": cfg['reindexer']['source_url'] },
"index": cfg['reindexer']['source_index'], "index": cfg['reindexer']['source_index'],
"type": "_doc", "type": "_doc",
"size": 100 "size": 100
...@@ -53,10 +57,15 @@ def main(cfg, wait=True): ...@@ -53,10 +57,15 @@ def main(cfg, wait=True):
} }
} }
# print(body) if 'source_url' in cfg['reindexer'].keys():
body['source']['remote'] = cfg['reindexer']['source_url']
logging.debug(body)
rep = es.reindex(body, wait_for_completion=False) #, slices=24)#, timeout='120s')# timeout='120s', slices=1000, requests_per_second=-1)#, timeout='2m') rep = es.reindex(body, wait_for_completion=False) #, slices=24)#, timeout='120s')# timeout='120s', slices=1000, requests_per_second=-1)#, timeout='2m')
logging.info(rep)
if 'task' in rep: if 'task' in rep:
# logging the indexing session into MongoDB # logging the indexing session into MongoDB
mongo_client = MongoClient('mongodb://%s:%s@%s:%s/' % (cfg['mongo']['username'], mongo_client = MongoClient('mongodb://%s:%s@%s:%s/' % (cfg['mongo']['username'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment