Content-Type header [application/x-www-form-urlencoded] is not supported on Elasticsearch

后端 未结 3 2059
无人及你
无人及你 2020-12-02 13:43

I used to have ElasticSearch 5.2, and just upgraded to 6.0.

I am trying to create an index template following guide here, but got error

Content-Type         


        
相关标签:
3条回答
  • 2020-12-02 14:19

    To fix this, add curl option -H 'Content-Type: application/json'


    This error is due to strict content-type checking introduced in ElasticSearch 6.0, as explained in this post

    Starting from Elasticsearch 6.0, all REST requests that include a body must also provide the correct content-type for that body.

    0 讨论(0)
  • 2020-12-02 14:35

    The solution is to add Content-Type: application/json header

    curl -XPUT 'localhost:9200/_template/template_1' \
      -H 'Content-Type: application/json' \
      -d '**your query**'
    
    0 讨论(0)
  • 2020-12-02 14:38
    "{ \"name\": { \"first\": {} }, \"address\": [ { \"address1\":\"lane\" } ] } "
    

    In Windows, when you give JSON as a parameter, use double quotes only. Use escape character.

    0 讨论(0)
提交回复
热议问题