As stated in the title, when I try to use the index API in python to index a json document, I get this error every time. I am brand new to the ELK stack but have followed the quick start guides on their website and I have been stuck here for quite some time. If any one could provide some insight into what's going here that would much appreciated. Thank you!!
Below is the code that I am running to try and index my document.
from elasticsearch import Elasticsearch
import configparser
import json
data_file_name = "/home/phil/PcapFiles/test1.json"
config_file_name = "/home/phil/ElasticPython/configuration.ini"
# Load config file for elastic user for ElasticSearch
config = configparser.ConfigParser()
config.read(config_file_name)
# Create the client instance
client = Elasticsearch(
cloud_id=config["ELASTIC"]["cloud_id"],
http_auth=(config["ELASTIC"]["user"], config["ELASTIC"]["password"])
)
# Successful response!
print("\n\nConnection Status Server Response...")
print("--------------------------------------------------------------\n")
print(client.info())
# create new index (like a new table in a database)
#print("\n\nIndex Creation Server Response...")
#print("---------------------------------------------------------------\n")
#resp = client.indices.create("test_network_data")
#print(resp)
# refresh newly created index
client.indices.refresh(index="test_network_data")
# send json formated data to ElasticSearch server
print("\n\nData Transmission Server Response...")
print("---------------------------------------------------------------\n")
f = open(data_file_name)
f_content = f.read()
response = client.index(index="test_network_data", ignore=400, doc_type="json", id=1, document=json.loads(f_content))
print(response)