Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indexing a data through curl throwing MapperParsingException?

I uesd following command from elasticsearch tutorial,

curl -XPUT "http://localhost:9200/movies/movie/1" -d" { "title": "The Godfather","director": "Francis Ford Coppola","year": 1972}"

Which produces following error:

{
    "error":"MapperParsingException[failed to parse]; nested: JsonParseException[Unrecognized token 'The': was expecting ('true', 'false' or 'null')
             at [Source: [B@d809e3; line: 1, column: 27]]; ",
    "status":400
}

curl: (6) Could not resolve host: Godfather,director
curl: (6) Could not resolve host: Ford
curl: (3) [globbing] unmatched close brace/bracket in column 19

Could anyone please help, what i need to do to rectify this error?

like image 812
Pankaj Kumar Avatar asked Dec 11 '22 06:12

Pankaj Kumar


2 Answers

The problem is that you use the same quote sign for properties and values inside the JSON object as well as the document itself which you are passing to curl.

Run this command instead:

curl -XPUT "http://localhost:9200/movies/movie/1" -d '{
  "title": "The Godfather",
  "director": "Francis Ford Coppola",
  "year": 1972
}'

Update:

since you are running the command on windows, the above solution won't work, instead your answer can be answered here:

This resulting command should work:

curl -X PUT "http://localhost:9200/movies/movie/1" -d "{ 
  ""title"": ""The Godfather"",
  ""director"": ""Francis Ford Coppola"",
  ""year"": 1972
}"
like image 55
peter Avatar answered Mar 03 '23 18:03

peter


I think you are struggling more in curl commands.

Try to use sense plug in in Chrome or Crest client extension for chrome..

https://chrome.google.com/webstore/detail/dev-http-client/aejoelaoggembcahagimdiliamlcdmfm?hl=en

https://chrome.google.com/webstore/detail/sense/doinijnbnggojdlcjifpdckfokbbfpbo?hl=en

It is very easy to use and easy understandable..

like image 26
BlackPOP Avatar answered Mar 03 '23 16:03

BlackPOP