Skip to content

Instantly share code, notes, and snippets.

@binhngoc17
Created March 31, 2015 05:41
Show Gist options
  • Save binhngoc17/c42727174eec2f783589 to your computer and use it in GitHub Desktop.
Save binhngoc17/c42727174eec2f783589 to your computer and use it in GitHub Desktop.
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