I have created a index like
> PUT new_index_blob
> {
> "mappings": {
> "properties": {
> "name": {
> "type": "text"
> },
> "blob": {
> "type": "binary",
> "store": true
> }
> }
> }
> }
When I am trying to store a Base64 encoded binary value from dev tool like below , it working fine
> PUT new_index_blob/_doc/1
> {
> "name": "Test",
> "blob": "U29tZSBiaW5hcnkgYmxvYg=="
> }
I am able to get/search the same from dev tools
GET /new_index_blob/_source/1
But when I am trying to store the same using python REST API its not working , not giving any error too , below code snippet
path = "C:\\Users\\Administrator\\Desktop\\POC_LOG_Collector\\"
name= "100.97.16.31_2020_Jul_17_09_14.zip" # 53 MB
zip_file_path = os.path.join(path, name)
elastic_url= "http://%s/%s/%s"%(
"localhost:9200",
"new_index_blob",
"_doc/2"
)
try:
data = open(zip_file_path, "rb").read()
encoded = str(base64.b64encode(data))
upload_data={}
upload_data["name"]=name
upload_data["blob"]=encoded
except Exception as e:
print(str(e))
try:
resp_elastic = requests.put(
elastic_url,
headers=headers,
data=json.dumps(upload_data),
verify=False
)
print("ES Entry completed for {}".format(name))
except Exception as e:
print(e)
What is the mistake I am doing . Also even after inserting it from Dev Tools the Doc count is showing 0 , is it expected for datatype binary with store true
.