인덱스 템플릿 시뮬레이션 API
인덱스 템플릿 시뮬레이션 API (Simulate Index Templates API)
1.0부터 도입되었어요.
인덱스 템플릿 시뮬레이션(Simulate Index Template) API를 사용해 인덱스 템플릿이 인덱스에 어떻게 적용될지 미리 보거나, 템플릿을 만들기 전에 시뮬레이션해 볼 수 있어요.
출처: 문서
본문
엔드포인트
POST /_index_template/_simulate
POST /_index_template/_simulate/{template_name}
POST /_index_template/_simulate_index/{index_name}
경로 파라미터
사용할 수 있는 경로 파라미터는 아래 표와 같아요.
| 파라미터 | 데이터 타입 | 설명 |
|---|---|---|
template_name |
String | 시뮬레이션할 인덱스 템플릿의 이름이에요. |
index_name |
String | 템플릿 해석을 시뮬레이션하는 데 사용할 인덱스의 이름이에요. |
요청 본문 필드
사용할 수 있는 요청 본문 필드는 아래 표와 같아요.
| 필드 | 데이터 타입 | 설명 |
|---|---|---|
index_patterns |
Array | 템플릿이 적용되는 인덱스 패턴이에요. |
template |
Object | 템플릿 정의예요. |
template.settings |
Object | 적용할 인덱스 설정이에요. |
template.mappings |
Object | 적용할 필드 매핑이에요. |
template.aliases |
Object | 적용할 별칭이에요. |
priority |
Integer | 템플릿의 우선순위 값이에요. 여러 템플릿이 인덱스와 일치할 때 어떤 템플릿이 적용될지 결정하는 데 사용해요. 값이 클수록 우선이에요. |
version |
Integer | 템플릿 버전이에요. |
_meta |
Object | 템플릿의 메타데이터예요. |
요청 예시: 템플릿 시뮬레이션
다음 요청을 사용해 템플릿을 만들지 않고 시뮬레이션해요:
POST /_index_template/_simulate_index/logs-sim-1
요청 예시: 이름이 있는 템플릿 시뮬레이션
POST /_index_template/_simulate/template_for_simulation
템플릿의 이름을 지정하면 특정 템플릿을 시뮬레이션할 수 있어요.
먼저 다음 요청으로 template_for_simulation이라는 템플릿을 만들어요:
PUT /_index_template/template_for_simulation
{
"index_patterns": [
"logs-sim-*"
],
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"timestamp": {
"type": "date"
},
"message": {
"type": "text"
},
"level": {
"type": "keyword"
}
}
}
},
"priority": 10,
"version": 1,
"_meta": {
"description": "Template used for simulation example",
"owner": "Docs Team"
}
}
이제 template_for_simulation이라는 템플릿을 시뮬레이션할 수 있어요:
POST /_index_template/_simulate/template_for_simulation
요청 예시: 특정 인덱스에서 템플릿 시뮬레이션
특정 인덱스 이름에서 템플릿을 시뮬레이션하는 것은 템플릿 간 충돌을 해결하거나 우선순위 문제를 디버깅할 때 특히 유용해요. 다음 요청은 겹치는 인덱스 패턴을 가진 적용 가능한 모든 템플릿이 logs-sim-1이라는 인덱스에 어떻게 적용될지를 보여줘요:
POST /_index_template/_simulate_index/logs-sim-1
응답 예시
{
"template": {
"settings": {
"index": {
"number_of_shards": "1",
"number_of_replicas": "1"
}
},
"mappings": {
"properties": {
"level": {
"type": "keyword"
},
"message": {
"type": "text"
},
"timestamp": {
"type": "date"
}
}
},
"aliases": {}
},
"overlapping": []
}
응답 본문 필드
| 필드 | 데이터 타입 | 설명 |
|---|---|---|
template |
Object | 적용된 템플릿이에요. |
template.settings |
Object | 해석된 인덱스 설정이에요. |
template.mappings |
Object | 해석된 필드 매핑이에요. |
template.aliases |
Object | 해석된 별칭이에요. |
overlapping |
Array | 같은 인덱스 패턴과 일치하지만 적용되지 않은 다른 인덱스 템플릿 목록이에요. |
필요한 권한
보안 플러그인을 사용한다면 다음 권한이 필요해요: indices:admin/index_template/simulate.