developer tip

Content-Type 헤더 [application / x-www-form-urlencoded]는 Elasticsearch에서 지원되지 않습니다.

optionbox 2020. 8. 19. 07:57
반응형

Content-Type 헤더 [application / x-www-form-urlencoded]는 Elasticsearch에서 지원되지 않습니다.


저는 ElasticSearch 5.2를 사용했고 방금 6.0으로 업그레이드했습니다.

여기 가이드에 따라 색인 템플릿을 만들려고하는데 오류가 발생했습니다.

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

내 질문은

curl -X PUT localhost:9200/_template/template_1 -d '
{
  "index_patterns": ["te*", "bar*"],
  "mappings": {
    "type1": {
      "properties": {
        "host_name": {
          "type": "keyword"
        }
      }
    }
  }
}'

이 문제를 해결하려면 curl 옵션을 추가하세요. -H 'Content-Type: application/json'


이 오류는 이 게시물에 설명 된대로 ElasticSearch 6.0에 도입 된 엄격한 콘텐츠 유형 검사 로 인해 발생합니다.

Elasticsearch 6.0부터 본문을 포함하는 모든 REST 요청은 해당 본문에 대한 올바른 콘텐츠 유형도 제공해야합니다.


해결책은 Content-Type: application/json헤더 를 추가하는 것입니다.

curl -XPUT 'localhost:9200/_template/template_1' \
  -H 'Content-Type: application/json' \
  -d '**your query**'

참고 URL : https://stackoverflow.com/questions/47544966/content-type-header-application-x-www-form-urlencoded-is-not-supported-on-elas

반응형