[elasticsearch] Elasticsearch에서 콘텐츠 유형 헤더 [application / x-www-form-urlencoded]가 지원되지 않습니다

이전에는 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**'


답변

"{ \"name\": { \"first\": {} }, \"address\": [ { \"address1\":\"lane\" } ] } "

Windows에서 JSON을 매개 변수로 제공 할 때는 큰 따옴표 만 사용하십시오. 이스케이프 문자를 사용하십시오.


답변