Loading json file in ES 6.4


(sami) #1

in 6.4 I am getting error trying to load the index

$ curl -XPUT node1:9200/test2idx --data-binary -H'Content-Type: application/json' @test.json
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}curl: (6) Could not resolve host: test.json; Name or service not known


(Mark Walkom) #2

That is not the right format for curl, you need to use the -d flag to pass in the file.


(sami) #3

can you please give me the right syntax?


(sami) #4

even creating the index is not working ,this example is from the ES site.

$ curl -XPUT http://node1:9200/shakespeare -d '

{
"mappings" : {
"default" : {
"properties" : {
"speaker" : {"type": "string", "index" : "not_analyzed" },
"play_name" : {"type": "string", "index" : "not_analyzed" },
"line_id" : { "type" : "integer" },
"speech_number" : { "type" : "integer" }
}
}
}
}
';
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}[elasticsearch@dotstohdadn201 ~]$
[elasticsearch@node1 ~]$


(sami) #5

I also tried using -H content type syntax , got different error

[elasticsearch@node1 ~]$ curl -XPUT http://node1:9200/shakespeare -H 'Content-Type: application/json' -d '

{
"mappings" : {
"default" : {
"properties" : {
"speaker" : {"type": "string", "index" : "not_analyzed" },
"play_name" : {"type": "string", "index" : "not_analyzed" },
"line_id" : { "type" : "integer" },
"speech_number" : { "type" : "integer" }
}
}
}
}
';
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"No handler for type [string] declared on field [play_name]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [default]: No handler for type [string] declared on field [play_name]","caused_by":{"type":"mapper_parsing_exception","reason":"No handler for type [string] declared on field [play_name]"}},"status":400}[elasticsearch@node1 ~]$
[elasticsearch@node1 ~]$


(Mark Walkom) #6

Can you link us to the document page you are reading?


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.