I am trying to do a curl call to post my JSON to Elastic search. My JSON file has the following data.
[
{
name1:val1,
name2:val2
},
{
name1:val3,
name2:val4
}
]
Since the JSON starts with array I get a mapping exception when I try to POST The data to ElasticSearch.
ERROR:
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"not_x_content_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"}},"status":400}LM-SJC-11002568
If i change my JSON to the below format, I am able to post the data to elastic search.
{
"result":[
{
name1:val1,
name2:val2
},
{
name1:val3,
name2:val4
}
]
}
But performing analysis on this JSON is not yielding correct results. Because it considers only the "result" while counting the number of documents and hence the "total" is always "1".
My ElasticSearch JSON:
{
"took":16,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"failed":0
},
"hits":{
"total":1,
"max_score":1,
"hits":[
{
"_index":"testing",
"_type":"1",
"_id":"******",
"_score":1,
"_source":{
"result":[
{
name1:val1,
name2:val2
},
{
name1:val3,
name2:val4
}
]
}
}
NOTE: Total is one though result has two documents inside it. I need a way to upload the Json Array directly into elasticSearch