ElasticStack/Elasticsearch
index template
닉의네임
2021. 10. 13. 23:23
반응형
Elasticsearch :
PUT _component_template/component_template1
{
"template": {
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
}
}
}
}
}
PUT _component_template/runtime_component_template
{
"template": {
"mappings": {
"runtime": {
"day_of_week": {
"type": "keyword",
"script": {
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
}
}
}
}
}
}
PUT _index_template/template_1
{
"index_patterns": ["te*", "bar*"],
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas":0
},
"mappings": {
"_source": {
"enabled": true
},
"properties": {
"host_name": {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
}
}
},
"aliases": {
"mydata": { }
}
},
"priority": 500,
"composed_of": ["component_template1", "runtime_component_template"],
"version": 3,
"_meta": {
"description": "my custom"
}
}
index pattern 에 맞는 데이터 입력
POST test/_doc/1
{
"host_name": "localhost"
}
index meta data 확인
{
"version": 4,
"mapping_version": 1,
"settings_version": 1,
"aliases_version": 1,
"routing_num_shards": 1024,
"state": "open",
"settings": {
"index": {
"routing": {
"allocation": {
"include": {
"_tier_preference": "data_content"
}
}
},
"number_of_shards": "1",
"provided_name": "test",
"creation_date": "1634135526525",
"number_of_replicas": "0",
"uuid": "PvNGwN24Tpm454KGxGlbSA",
"version": {
"created": "7130499"
}
}
},
"mappings": {
"_doc": {
"runtime": {
"day_of_week": {
"type": "keyword",
"script": {
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))",
"lang": "painless"
}
}
},
"properties": {
"@timestamp": {
"type": "date"
},
"created_at": {
"format": "EEE MMM dd HH:mm:ss Z yyyy",
"type": "date"
},
"host_name": {
"type": "keyword"
}
}
}
},
"aliases": [
"mydata"
],
"primary_terms": {
"0": 1
},
"in_sync_allocations": {
"0": [
"i-GeIPcpRJusyzYNErecnQ"
]
},
"rollover_info": { },
"system": false,
"timestamp_range": {
"unknown": true
}
}
반응형