Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Import data from file to elasticsearch (python)
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
You can’t perform that action at this time.