elasticsearch index templates 만들기
가이드 : http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html
1. GET을 이용한 저장된 전체 인덱스 템플릿가져오기
$ curl -XGET localhost:9200/_template/
{"logstash":{"order":0,"template":"logstash-*","settings":{"index.refresh_interval":"5s"},"mappings":{"_default_":{"dynamic_templates":[{"string_fields":{"mapping":{"index":"analyzed","omit_norms":true,"type":"string","fields":{"raw":{"index":"not_analyzed","ignore_above":256,"type":"string"}}},"match_mapping_type":"string","match":"*"}}],"properties":{"geoip":{"dynamic":true,"path":"full","properties":{"location":{"type":"geo_point"}},"type":"object"},"@version":{"index":"not_analyzed","type":"string"}},"_all":{"enabled":true}}},"aliases":{}},"nginx_log":{"order":0,"template":"nginx_log-*","settings":{"index.refresh_interval":"5s"},"mappings":{"_default_":{"dynamic_templates":[{"string_fields":{"mapping":{"index":"analyzed","omit_norms":true,"type":"string","fields":{"raw":{"index":"not_analyzed","ignore_above":256,"type":"string"}}},"match":"*","match_mapping_type":"string"}}],"properties":{"geoip":{"dynamic":true,"path":"full","properties":{"location":{"type":"geo_point"}},"type":"object"},"@version":{"index":"not_analyzed","type":"string"}},"_all":{"enabled":true}}},"aliases":{}}}
※ 2개 logstash / nginx_log 두개 인덱스 템플릿 등록된게 보인다
2. GET을 이용해서 하나만 지정해서 보기
$ curl -XGET localhost:9200/_template/nginx_log
{"nginx_log":{"order":0,"template":"nginx_log-*","settings":{"index.refresh_interval":"5s"},"mappings":{"_default_":{"dynamic_templates":[{"string_fields":{"mapping":{"index":"analyzed","omit_norms":true,"type":"string","fields":{"raw":{"index":"not_analyzed","ignore_above":256,"type":"string"}}},"match":"*","match_mapping_type":"string"}}],"properties":{"geoip":{"dynamic":true,"path":"full","properties":{"location":{"type":"geo_point"}},"type":"object"},"@version":{"index":"not_analyzed","type":"string"}},"_all":{"enabled":true}}},"aliases":{}}}
3. PUT 신규 템플릿 신규 등록
$ curl -XPUT localhost:9200/_template/nginx_log2 -d '
> {
> "order":0,
> "template":"nginx_log2-*",
> "settings":{
> "index.refresh_interval":"5s"
> },
> "mappings":{
> "_default_":{
> "dynamic_templates":[{
> "string_fields":{
> "mapping":{
> "index":"analyzed",
> "omit_norms":true,
> "type":"string",
> "fields":{
> "raw":{
> "index":"not_analyzed",
> "ignore_above":256,
> "type":"string"
> }
> }
> },
> "match_mapping_type":"string",
> "match":"*"
> }
> }
> ],
> "properties":{
> "geoip":{
> "dynamic":true,
> "path":"full",
> "properties":{
> "location":{
> "type":"geo_point"
> }
> },
> "type":"object"
> },
> "@version":{
> "index":"not_analyzed",
> "type":"string"
> }
> },
> "_all":{
> "enabled":true
> }
> }
> },
> "aliases":{
> }
> }'
{"acknowledged":true}
4. DELETE 템플릿 삭제
$ curl -XDELETE localhost:9200/_template/nginx_log2
{"acknowledged":true}
이것 외에도 GET할때 여러개 템플릿 같이 보기등 가이드사이트 가면 몇가지 예시 더 있음 참고할것!~