Search code examples
elasticsearchcurl

unexpected EOF while looking for matching `"'


I am using XPUT command in ElasticSearch and writing the correct command but getting same error again and again.

My code:

curl -XPUT 127.0.0.1:9200/movies -d '
{
        "mappings": {
                "properties": {
                        "year": {
                                "type": "date"
                        }
                }
        }
}'

And error is :

unexpected EOF while looking for matching `"'

I am following course on udemy and the instructor is writing the same command and getting the work done.


Solution

  • Try like this:

    curl -XPUT "http://localhost:9200/movies" -H "Content-Type: application/json" -d'
    {
      "mappings": {
        "properties": {
          "year": {
            "type": "date"
          }
        }
      }
    }'
    

    Note: Use https and -k flag in the curl request if Elasticsearch http layer security is enabled.

    If you have kibana you can run like the following:

    PUT movies
    {
      "mappings": {
        "properties": {
          "year": {
            "type": "date"
          }
        }
      }
    }