from elasticsearch import Elasticsearch

class Indexer(object):
    def __init__(self, index_name, doc_type):
        # create an Elasticsearch index
        es = Elasticsearch([{'host': 'localhost', 'port': '9200'}])

        self.index_name = index_name
        self.es = es
        self.doc_type = doc_type

    def index(self, doc_id=None, doc_body=None):
        self.es.index(
            index=self.index_name,
            doc_type=self.doc_type,
            id=doc_id,
            body=doc_body)




@@ -32,16 +32,28 @@
 icsearch
+%0Aimport json
 %0A%0Aclass 
@@ -111,24 +111,216 @@
  doc_type):%0A
+%0A        # Load configuration from file%0A        with open(%22../config.json%22, %22r%22) as fig:%0A            config = json.load(fig)%0A%0A        host = config%5B'host'%5D%0A        port = int(config%5B'port'%5D)%0A%0A
         # cr
@@ -388,19 +388,12 @@
 t': 
-'local
 host
-'
 , 'p
@@ -402,14 +402,12 @@
 t': 
-'9200'
+port
 %7D%5D)%0A
@@ -692,11 +692,8 @@
 c_body)%0A
-%0A%0A%0A

Read Elasticsearch config from configuration file for Indexer