Last active
May 22, 2019 23:09
-
-
Save icamys/d9659e3b0d9d068a07964449dd58265f to your computer and use it in GitHub Desktop.
Import data from file to elasticsearch (python)
This file contains 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
import json | |
from elasticsearch import Elasticsearch | |
filename = './import-files/data.json' | |
es = Elasticsearch("http://localhost:9200", http_auth=('elastic', 'changeme')) | |
i = 1 | |
f = open(filename) | |
for line in f: | |
es.index(index='domains', ignore=400, doc_type='domain_data', id=i, body=json.loads(line)) | |
i = i + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment