Quite new to Elasticsearch and I am trying to read in .json file and trying to index the file. So far I have this but I am kind of unsure on how to proceed from here:
from elasticsearch import Elasticsearch, helpers
import json, sys
es = Elasticsearch()
def load(filename):
if filename.endswith('.json'):
with open(filename, 'r') as open_file:
yield json.load(open_file)
helpers.bulk(es, load(sys.argv[1]), index='my-index', doc_type='my-type')
When I run this, I get error: helpers.bulk(es, load_json(sys.argv[1]), index='my-index', doc_type='my-type')
IndexError: list index out of range
load_json' orload` . You have 2 different in the question