# Error Handling Note
Elasticsearch 7.9 ๋ฒ์ ์ ์ฌ์ฉํ๋ฉด์ ๋ฐ์ํ Error๋ฅผ ์ ๋ฆฌํ์๋ค.
# ์ค์ต ํ๊ฒฝ
- ๐ก Elasticsearch 7.9.0
- ๐ก Windows 10
- ๐ก Git Bash
# header not supported Error
# ๋ฌธ์ ์
2020.08.21
ES
์์ index
๋ฅผ ์์ฑํ๊ณ ํ์ธํ๊ณ ์ญ์ ํ ๋๋ ์๋ฌด Error๊ฐ ๋์ง ์์๋๋ฐ
Document
๋ฅผ ๋ง๋ค ๋ ๋ค์๊ณผ ๊ฐ์ Error๊ฐ ๋ฐ์ํ๋ค.
{
"error" : "Content-Type header [application/x-www-form-urlencoded] is not supported",
"status" : 406
}
# ์์ธ
Elasticsearch
6.0 ์ดํ ๋ฒ์ ์ ๋์
๋ ์
๊ฒฉํ content-type ํ์ธ (opens new window)์ผ๋ก ์ธํด ๋ฐ์ํ๋ Error์ด๋ค.
# ํด๊ฒฐ๋ฐฉ๋ฒ
curl
๋ช
๋ น์ด์ ์ต์
์ ๋ค์๊ณผ ๊ฐ์ด ์ถ๊ฐํด์ ์คํํด์ผ ํ๋ค.
-H 'Content-Type: application/json'
# Example
Error ์ํฉ
$ curl -XPOST http://localhost:9200/classes/class/1/?pretty -d @oneclass.json
{
"error" : "Content-Type header [application/x-www-form-urlencoded] is not supported",
"status" : 406
}
ํด๊ฒฐ
$ curl -XPOST http://localhost:9200/classes/class/1/?pretty -H 'Content-Type: application/json' -d @oneclass.json
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 394 100 222 100 172 1734 1343 --:--:-- --:--:-- --:--:-- 3078{
"_index" : "classes",
"_type" : "class",
"_id" : "1",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
# Could not resolve host: application
# ๋ฌธ์ ์
2020.08.21
Windows10 ๊ฐ๋ฐ ํ๊ฒฝ์์ Elasticsearch๋ฅผ ํ
์คํธ ์ค์ ์ header
๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ๋ฏ ํ์๋๋ฐ ์๋์ ์ด๋ฐ Error
๊ฐ ๋ ์์๋ค.
curl: (6) Could not resolve host: application
# ์์ธ
Cmder (opens new window)์ด๋ผ๋ Windows ์ฝ์ ์๋ฎฌ๋ ์ดํฐ๋ฅผ ์ฌ์ฉํ๋ฉด ls
์ ๊ฐ์ ๋ช
๋ น์ด๋ฅผ ์ฌ์ฉํ ์ ์๊ธฐ ๋๋ฌธ์ ๊ด์ฐฎ์ ์ค ์์์ง๋ง Unix ๋ช
๋ น์ด๋ฅผ ์ค๋ฅ์์ด ์ฌ์ฉํ๋ ๊ฒ์ ์์ง ์๋๋ ๊ฒ ๊ฐ๋ค.
# ํด๊ฒฐ๋ฐฉ๋ฒ
Git Bash (opens new window)๋ฅผ ์ฌ์ฉํด ๋๊ฐ์ ๋ช ๋ น์ด๋ฅผ ์์ฑํ๋๋ฐ ์ ๋๋ค.
Cmder์ ์ญ์ ํด์ผ๊ฒ ๋ค.
# The Bulk request must be terminated by a newline [\n]
# ๋ฌธ์ ์
JSON file
์ Bulk ํ๋ ๊ณผ์ ์์ Error ๊ฐ ๋ฐ์ํ๋ค.
2020.08.21
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [\\n]"
}
],
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [\\n]"
},
"status" : 400
}
# ์์ธ
Error ์ค๋ช
๋๋ก New Line
์ผ๋ก ๋๋์ผ๋๋๋ฐ New Line
์ด ์์ด์ ๊ทธ๋ฐ ๊ฒ ๊ฐ๋ค.
# ํด๊ฒฐ๋ฐฉ๋ฒ
JSON file์ ์ํฐ๋ฅผ ๋ ๋ฒ ์ณค๋ค.
์ด๋ ๊ฒ ๋จ์ํ Error๋ ์ ์ง๋ ๋ง์์ผ๊ฒ ๋ค. Error ์ก๋ ์๊ฐ๋ณด๋ค ์ ๋ฆฌํ๋๊ฒ ๋ ์ค๋๊ฑธ๋ ธ์
# Mapping ์ค์ ์์ ๋ฌธ์ ์ (Elasticsearch 7.x ๋ฒ์ )
2020.08.24
# โ ๋ฌธ์ ์
Elasticsearch 7.x ๋ฒ์ ์์ Mapping
์ ์์ฑํ๋ ์ค์ต ๋์ค ์๋ฌ๊ฐ ๋ฐ์ํ๋ค.
์๋ฌ๋ฌธ๊ตฌ๋ ๋ค์๊ณผ ๊ฐ๋ค.
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."
}
],
"type" : "illegal_argument_exception",
"reason" : "Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."
},
"status" : 400
}
# ์์ธ
Elasticsearch 7.x
๋ฒ์ ๋ถํฐ๋curl
๋ฆฌํ์คํธ์์ ํค๋๋ฅผ ๋ช ํํ ์ค์ ํด์ฃผ์ด์ผ ํ๋ค.mapping
์ ์์ฑํ ๋์๋include_type_name
์true
๋ก ์ค์ ํด์ฃผ์ด์ผ ํ๋ค.
# ํด๊ฒฐ๋ฐฉ๋ฒ
# 1๏ธโฃ mapping
์ ์์ฑํ ๋ ์๋์ ๊ฐ์ด Content-Type ์ถ๊ฐ
-H 'Content-Type: application/json'
์ ์ฒด ์ปค๋ฉ๋ ๋ผ์ธ
$ curl -XPUT http://localhost:9200/classes/class/_mapping -d @classesRating_mapping.json -H 'Content-Type: application/json'
๋ค๋ฅธ ์๋ฌ ๋ฐ์
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."
}
],
"type" : "illegal_argument_exception",
"reason" : "Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."
},
"status" : 400
}
์ด ์๋ฌ์ ๋ํด Elasticsearch ๊ณต์ ๋ฌธ์ (opens new window)๋ฅผ ์ฐพ์๋ณด๋ฉด 7.0 ๋ฒ์ ๋ถํฐ๋ ๋ฌดํ์ API๋ฅผ ๋์ ํจ์ ๋ฐ๋ผ
include_type_name=true๋ฅผ ์ธ๋ฑ์ค ์์ฑ, ํ ํ๋ฆฟ, ๋งคํ API๋ก ์ ๋ฌ ํ๋ผ๋ ๋ด์ฉ์ด ์๋ค.
์ถ๊ฐํด๋ณด์๋ค.
# 2๏ธโฃ include_type_name=true
์ถ๊ฐ
$ curl -XPUT 'http://localhost:9200/classes/class/_mapping?include_type_name=true&pretty' -d @classesRating_mapping.json -H 'Content-Type: application/json'
๋ ๋ค๋ฅธ ์๋ฌ๊ฐ ๋ฐ์ํ๋ค.
{
"error" : {
"root_cause" : [
{
"type" : "mapper_parsing_exception",
"reason" : "No handler for type [string] declared on field [professor]"
}
],
"type" : "mapper_parsing_exception",
"reason" : "No handler for type [string] declared on field [professor]"
},
"status" : 400
}
์ด ์์ธ์ stackoverflow (opens new window)์์ ์ฐพ์ ์ ์๋๋ฐ 6.0 ๋ฒ์ ์ด์๋ถํฐ Mapping Type ์ค String
์ ์ญ์ ํ๊ณ text
๋ก ๋ณ๊ฒฝํ์ฌ ์ฌ์ฉํ๋ค๊ณ ํ๋ค.
๋ฐ๋ผ์ ๊ธฐ์กด์ mapping ํ์ ์ค string์ ์ญ์ ํ๋ฉด ํด๊ฒฐ๋๋ค.
์ฐธ๊ณ ํ ๊ธ (opens new window)