code: def create_index_from_json(index_name, file_path, max_docs=None):
      """Create an index from json file formats.
      Read each file line by line, parse each line as json
          jsonl.xz
          json  : must be a json file containing a list
  
      Arguments:
          file_path {str} -- path to case.law bulk file
      Keyword Arguments:
          max_docs {int} -- maximum size of records to use in creating index.
          small default can be used to enable quick testing (e.g: {2000}).
          set this to None to use the entire data file.
      """
      # print("*** maxdocs", max_docs)
      es = Elasticsearch([{"host": "localhost", "port": 9200}])
  
      es.indices.create(
          index=index_name, body=index_settings, ignore=400
      )
  
      extension = os.path.splitext(file_path)[1]
      logger.info(">> Creating index using file " + file_path)
      i = 0
      if extension == ".xz":
          with lzma.open(file_path) as f:
              for line in f:
                  i += 1
                  line = json.loads(str(line, "utf8"))
                  try:
                      index_status = es.index(
                          index=index_name, id=i, body=line
                      )
                      # print(index_status)
                  except Exception as e:
                      logger.info(
                          "An error has occurred while creating index "
                          + str(e)
                      )
                      break
                  # logger.info(index_status)
                  if i > max_docs:
                      break
      logger.info(">> Creating index complete, delete data file .. ")
      os.remove(file_path)
  
file_path: neuralqa/neuralqa/utils/data_utils.py
imports: from elasticsearch import Elasticsearch
  import os
  import zipfile
  import shutil
  import urllib.request
  import logging
  import lzma
  import json
  import tarfile
  import hashlib
label_desc: Use image node_id 1 for calling a global function with example usage: create_index_from_json(index_name, file_path, max_docs) without return types