Ignore malformed 매핑 파라미터
Ignore malformed 매핑 파라미터
ignore_malformed 매핑 파라미터는 필드의 기대 형식과 일치하지 않는 값을 인덱싱 엔진이 무시하도록 지시해요. 활성화하면 잘못된 형식의 값이 인덱싱되지 않아 데이터 형식 문제로 문서 전체가 거부되는 것을 방지해요.
출처: 문서
본문
ignore_malformed 매핑 파라미터는 필드의 기대 형식과 일치하지 않는 값을 인덱싱 엔진이 무시하도록 지시합니다. 활성화되면 잘못된 형식의 값이 인덱싱되지 않아 데이터 형식 문제 때문에 문서 전체가 거부되는 것을 방지합니다. 이는 하나 이상의 필드에 파싱할 수 없는 데이터가 포함되어 있어도 문서가 여전히 저장되도록 보장합니다.
기본적으로 ignore_malformed는 비활성화되어 있으며, 이는 값을 필드 유형에 따라 파싱할 수 없으면 전체 문서의 인덱싱이 실패함을 의미합니다.
예제: ignore_malformed 꺼짐
age 필드가 integer 유형인 people_no_ignore라는 인덱스를 만듭니다. 기본적으로 ignore_malformed는 false로 설정됩니다.
PUT /people_no_ignore
{
"mappings": {
"properties": {
"age": {
"type": "integer"
}
}
}
}
잘못된 형식의 값을 가진 문서를 인덱싱합니다.
PUT /people_no_ignore/_doc/1
{
"age": "twenty"
}
잘못된 형식의 값 때문에 요청이 실패합니다.
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to parse field [age] of type [integer] in document with id '1'. Preview of field's value: 'twenty'"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse field [age] of type [integer] in document with id '1'. Preview of field's value: 'twenty'",
"caused_by": {
"type": "number_format_exception",
"reason": "For input string: \"twenty\""
}
},
"status": 400
}
예제: ignore_malformed 켜짐
age 필드의 ignore_malformed를 true로 설정한 people_ignore라는 인덱스를 만듭니다.
PUT /people_ignore
{
"mappings": {
"properties": {
"age": {
"type": "integer",
"ignore_malformed": true
}
}
}
}
잘못된 형식의 값을 가진 문서를 인덱싱합니다.
PUT /people_ignore/_doc/1
{
"age": "twenty"
}
문서를 검색합니다.
GET /people_ignore/_doc/1
응답은 잘못된 형식의 값이 있음에도 문서가 성공적으로 인덱싱되었음을 보여 줍니다.
{
"_index": "people_ignore",
"_id": "1",
"_version": 1,
"_seq_no": 0,
"_primary_term": 1,
"found": true,
"_source": {
"age": "twenty"
}
}