0

I have tried to import json array file into elasticsearch using following commands,

curl -XPOST 'http://localhost:9200/unified/post/1' -d @unified.json

and

curl -XPOST 'http://localhost:9200/unified/post/_bulk' --data-binary @unified_1.json

But, it is throwing error message as

{"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}

Can anyone help me with this problem.

  • 1
    Can you show file that you want to import? – froosty Aug 26 '17 at 11:13
  • The bulk api does not expect json input. This is probably a duplicate of https://stackoverflow.com/questions/33340153/elasticsearch-bulk-index-json-data – dshockley Aug 26 '17 at 11:52
  • The input file will be as follows : [{"name1":"value1"},{"name2":"value2"},....] . So, can you guide us. – Sai Sri Krishna Kotha Aug 27 '17 at 12:37
  • You cannot use that input format. Check the [bulk api docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html). You have to write some code to transform your file into the format the bulk api expects. – dshockley Aug 29 '17 at 07:48

1 Answers1

0

The issue is with "@unified_1.json". It seems that the data inside is does not follow the appropriate json structure that is required.

ZiadM
  • 374
  • 2
  • 6
  • json file consists of array of jsons inside it. – Sai Sri Krishna Kotha Aug 27 '17 at 12:35
  • The json file should have the following structure. { "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } } { "field1" : "value1" } { "index" : { "_index" : "test", "_type" : "type1", "_id" : "2" } } { "field1" : "value1" } action then document json.. not as json array. please post a small part of the file to check it – ZiadM Aug 28 '17 at 14:06