Created
March 31, 2015 05:41
-
-
Save binhngoc17/c42727174eec2f783589 to your computer and use it in GitHub Desktop.
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
from django.conf import settings | |
import elasticsearch | |
from elasticsearch.helpers import scan | |
from zopim.util.es_lib import BulkIndexerV2 | |
bulk = BulkIndexerV2() | |
es1 = elasticsearch.Elasticsearch(['esproxy.zopim.net:80']) | |
es2 = elasticsearch.Elasticsearch(settings.ES_HOSTS) | |
scan_resp = scan( | |
client=es1, | |
index='eventlog-*', | |
query= { | |
"query": { | |
"term": { | |
"agent_id": 1767963 | |
} | |
} | |
} | |
) | |
print 'Hi' | |
for doc in scan_resp: | |
bulk.add( | |
_index=doc['_index'], | |
_type=doc['_type'], | |
doc=doc['_source'] | |
) | |
bulk.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment