Loading json file in ES 6.4

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

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

can you please give me the right syntax?

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 ~]$

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 ~]$

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

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