[ Index template ]
보통 날짜별로 elasticsearch에 index를 생성하여 사용하는데
매번 데이터가 들어올 때 마다 mapping을 통해 field type을 지정하지 않기 위해
Index template를 사용한다.
생성 예시
* 일별로 log-20220101, log-20220101 형식으로 인덱스 생성된다.
PUT _template/log_template
{
"order": 0,
"index_patterns": [
"log-20*"
],
"settings": {
"index": {
"number_of_shards": "1",
"number_of_replicas": "1",
}
},
"mappings": {
"properties": {
"user_id": {
"type": "long"
},
"name": {
"type": "text"
},
"sale": {
"type": "long"
},
"sale_date": {
"type": "date",
"format": "yyyy-MM-dd"
}
}
}
}
생성 template확인
GET _template/log_template
Field data types :
https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html
'DataPipeline > Elasticsearch' 카테고리의 다른 글
Logstash - Json, Mutate, Roby, Date (0) | 2024.11.26 |
---|---|
Logstach - dissect, grok 필터 예제 (0) | 2024.11.13 |
Elasticsearch - Reindex (0) | 2023.03.26 |
Elasticsearch - Opendistro Kibana 유저 확인, 추가, 삭제 (0) | 2023.03.26 |
Elasticsearch - Opendistro 와 Kibana 설치 (0) | 2023.03.26 |