Elastic Search
[ElasticSearch] Dynamic Template
miin1635@
2024. 1. 4. 15:55
PUT my-index-000001/
{
"mappings": {
"dynamic_templates": [
{
"strings_as_ip": {
"match_mapping_type": "string",
"match": "ip*",
"runtime": {
"type": "ip"
}
}
}
]
}
}
PUT my-index-000001
{
"mappings": {
"dynamic_templates": [
{
"integers": {
"match_mapping_type": "long",
"mapping": {
"type": "integer"
}
}
},
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"type": "text",
"fields": {
"raw": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
]
}
}
PUT my-index-000001/_doc/1
{
"my_integer": 5,
"my_string": "Some string"
}
즉, match_mapping_type 에 맞는 필드에 값이 들어갔을 때, 동적으로 타입을 변환하여 데이터를 적재해준다.