0

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

1
  • method name is load_json' or load` . You have 2 different in the question Commented Mar 22, 2018 at 1:04

1 Answer 1

1

The only issue I can see with is the arguments you are passing to the python code.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, I am not sure if I understand. Do you mean sys.argv[1] argument I am passing in load?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.