I tried to run a curl command from a python script to fetch anomaly results. The code is as follows:
BODY= '{"size": 10000, "query": {"bool": {"filter": [{"term": {"result_type": "record"}},{"range": {"record_score": {"gte": 75}}},{ "range" : { "multi_bucket_impact" : { "lt": "-4" } } }]}},"script_fields": {"timestamp_date": {"script": {"lang": "painless","source": "doc["timestamp"]"}},"record_score" : {"script": {"lang": "painless","source": "doc["record_score"].value"}},"SHIPPERID_CARRIERID" : {"script": {"lang": "painless","source": "doc["partition_field_value"]"}}}}'
try:
output= subprocess.check_output(["curl","-g","-XGET", "http://localhost:9200/.ml-anomalies-.write-my_job_low_sum/_search" ,"-H" ,"Content-Type: application/json", "-d", BODY])
print(output)
except Exception as e :
print(e)
But I'm getting the full error:
{"error":{"root_cause":[{"type":"x_content_parse_exception","reason":"[1:261] [script] failed to parse object"}],"type":"x_content_parse_exception","reason":"[1:261] [script] failed to parse object","caused_by":{"type":"json_parse_exception","reason":"Unexpected character ('t' (code 116)): was expecting comma to separate Object entries\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@45adfb41; line: 1, column: 268]"}},"status":400}
Can you explain the cause for this error and how to solve it?