{"id":336,"date":"2018-08-14T08:30:08","date_gmt":"2018-08-13T23:30:08","guid":{"rendered":"http:\/\/dong1lkim.oboki.net\/?p=336"},"modified":"2019-09-01T22:21:34","modified_gmt":"2019-09-01T13:21:34","slug":"elasticsearch-index-template","status":"publish","type":"post","link":"https:\/\/oboki.net\/workspace\/data-engineering\/elasticsearch\/elasticsearch-index-template\/","title":{"rendered":"[ElasticSearch] Index Template"},"content":{"rendered":"<h1>ElasticSearch Index templates<\/h1>\n<p>Index template\uc740 \uc0c8\ub85c\uc6b4 index\uac00 \uc0dd\uc131\ub420 \ub54c\uc5d0, index \uc124\uc815 \ub610\ub294 \ud2b9\uc815 \ud544\ub4dc\uc758 \ub370\uc774\ud130 \ud0c0\uc785\uc744 \uc815\uc758\ud574\uc900\ub2e4.<br \/>\nElasticSearch\uc5d0 Logstash \ub4f1 \uc218\uc9d1\uae30\ub85c \ub370\uc774\ud130 \uc218\uc9d1 \uc804 index\uac00 \uc0ac\uc804 \uc0dd\uc131\ub420 \ud544\uc694\uac00 \uc5c6\ub2e4. \uadf8\ub7f0\ub370 \uadf8\ub0e5 \uc218\uc9d1\ud558\uba74 \uc22b\uc790\ub098 \ub0a0\uc9dc\ub294 \uc54c\uc544\uc11c \ud30c\uc2f1\uc744 \ud558\ub294\ub370 \ub098\uba38\uc9c0 \ub300\ubd80\ubd84\uc740 text\ub85c \ud574\uc11d\ud55c\ub2e4.<br \/>\nindex template\ub97c \uc0dd\uc131\ud568\uc73c\ub85c\uc368 index\ubcc4\ub85c Shard \uac2f\uc218\ub098 \ud2b9\uc815 \ud544\ub4dc\uc5d0 \ub300\ud55c \uac1c\ubcc4\uc801\uc778 \uad00\ub9ac\ub97c \ud560 \uc218 \uc788\ub2e4.<\/p>\n<blockquote><p>\n  rdbms\uc758 ddl\uc740 \uc544\ub2c8\uc9c0\ub9cc \ube44\uc2b7\ud55c \ub290\ub08c.\n<\/p><\/blockquote>\n<p><a href=\"https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/guide\/2.x\/index-templates.html#index-templates\"><a href=\"https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/guide\/2.x\/index-templates.html#index-templates\">https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/guide\/2.x\/index-templates.html#index-templates<\/a><\/a><\/p>\n<h2>template \uc720\ubb34\uc5d0 \ub530\ub77c index \ucc28\uc774 \ud655\uc778<\/h2>\n<p>\uc544\ub798\uc640 \uac19\uc774 \/twitter\/_doc\/1  \ub370\uc774\ud130 \uc0dd\uc131\ud558\uba74,<\/p>\n<pre><code class=\"bash\">[elastic@node5 es_test]$ curl -X PUT \"node5.big:9200\/twitter\/_doc\/1?pretty\" -H 'Content-Type: application\/json' -d' \n{\n    \"user\" : \"kimchy\",\n    \"post_date\" : \"2009-11-15T14:12:12\",\n    \"message\" : \"trying out Elasticsearch\"\n}\n'\n<\/code><\/pre>\n<p>\ub2e4\uc74c\uacfc \uac19\uc774 \ucd94\uac00\ub41c \ub370\uc774\ud130\ub97c \ud655\uc778\ud560 \uc218 \uc788\ub2e4.<\/p>\n<pre><code class=\"bash\">[elastic@node5 es_test]$ curl -X GET 'node5.big:9200\/twitter\/_doc\/1?pretty'\n{\n  \"_index\" : \"twitter\",\n  \"_type\" : \"_doc\",\n  \"_id\" : \"1\",\n  \"_version\" : 1,\n  \"found\" : true,\n  \"_source\" : {\n    \"user\" : \"kimchy\",\n    \"post_date\" : \"2009-11-15T14:12:12\",\n    \"message\" : \"trying out Elasticsearch\"\n  }\n}\n<\/code><\/pre>\n<p>\uc774 \ub54c\uc5d0 twitter \uc778\ub371\uc2a4\uc758 \ub9e4\ud551\/\uc138\ud305 \uc815\ubcf4\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre><code class=\"bash\">[elastic@node5 es_test]$ curl -X GET 'node5.big:9200\/twitter\/_mapping\/?pretty'\n{\n  \"twitter\" : {\n    \"mappings\" : {\n      \"_doc\" : {\n        \"properties\" : {\n          \"message\" : {\n            \"type\" : \"text\",\n            \"fields\" : {\n              \"keyword\" : {\n                \"type\" : \"keyword\",\n                \"ignore_above\" : 256\n              }\n            }\n          },\n          \"post_date\" : {\n            \"type\" : \"date\"\n          },\n          \"user\" : {\n            \"type\" : \"text\",\n            \"fields\" : {\n              \"keyword\" : {\n                \"type\" : \"keyword\",\n                \"ignore_above\" : 256\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}\n\n[elastic@node5 es_test]$ curl -X GET 'node5.big:9200\/twitter\/_settings\/?pretty'\n{\n  \"twitter\" : {\n    \"settings\" : {\n      \"index\" : {\n        \"creation_date\" : \"1534209610122\",\n        \"number_of_shards\" : \"5\",\n        \"number_of_replicas\" : \"1\",\n        \"uuid\" : \"aO685Uu2T8OCnxnsXzMF8w\",\n        \"version\" : {\n          \"created\" : \"6020499\"\n        },\n        \"provided_name\" : \"twitter\"\n      }\n    }\n  }\n}\n<\/code><\/pre>\n<p>\uae30\uc874 \uc0dd\uc131\ub41c Twitter \uc778\ub371\uc2a4\ub97c \uc0ad\uc81c\ud558\uace0<\/p>\n<pre><code class=\"bash\">[elastic@node5 es_test]$ curl -X DELETE \"node5.big:9200\/twitter?pretty\"\n{\n  \"acknowledged\" : true\n}\n<\/code><\/pre>\n<p>\ub2e4\uc74c\uacfc \uac19\uc774 template_twitter \ub97c \uc0ac\uc804 \uc0dd\uc131\ud55c \ub4a4<\/p>\n<pre><code class=\"bash\">[elastic@node5 es_test]$ curl -X PUT \"node5.big:9200\/_template\/template_twitter?pretty\" -H 'Content-Type: application\/json' -d' \n{\n  \"template\" : \"twitter*\",\n  \"mappings\" : { \n    \"_doc\": {\n      \"properties\": {\n        \"message\": {\n          \"type\": \"text\"\n        },  \n        \"post_date\": {\n          \"type\": \"text\"\n        },  \n        \"user\": {\n          \"type\": \"text\"\n        }\n      }\n    }\n  },  \n  \"settings\": {\n    \"number_of_shards\": 2\n  }\n}\n'\n<\/code><\/pre>\n<p>\ub370\uc774\ud130\ub97c \ub2e4\uc2dc \uc0dd\uc131\ud558\uba74<\/p>\n<pre><code class=\"bash\">[elastic@node5 es_test]$ curl -X PUT \"node5.big:9200\/twitter\/_doc\/1?pretty\" -H 'Content-Type: application\/json' -d' \n{\n    \"user\" : \"kimchy\",\n    \"post_date\" : \"2009-11-15T14:12:12\",\n    \"message\" : \"trying out Elasticsearch\"\n}\n'\n<\/code><\/pre>\n<p>\uc544\ub798\uc640 \uac19\uc774 \ub370\uc774\ud130\ub294 \ub3d9\uc77c\ud558\uac8c \uc870\ud68c\uac00 \ub418\uba74\uc11c<\/p>\n<pre><code class=\"bash\">[elastic@node5 es_test]$ curl -X GET 'node5.big:9200\/twitter\/_doc\/1?pretty'\n{\n  \"_index\" : \"twitter\",\n  \"_type\" : \"_doc\",\n  \"_id\" : \"1\",\n  \"_version\" : 1,\n  \"found\" : true,\n  \"_source\" : {\n    \"user\" : \"kimchy\",\n    \"post_date\" : \"2009-11-15T14:12:12\",\n    \"message\" : \"trying out Elasticsearch\"\n  }\n}\n<\/code><\/pre>\n<p>\ub9e4\ud551\/\uc138\ud305 \uc815\ubcf4\uac00 \ub2e4\ub974\ub2e4.<\/p>\n<pre><code class=\"bash\">[elastic@node5 es_test]$ curl -X GET 'node5.big:9200\/twitter\/_mapping\/?pretty'\n{\n  \"twitter\" : {\n    \"mappings\" : {\n      \"_doc\" : {\n        \"properties\" : {\n          \"message\" : {\n            \"type\" : \"text\"\n          },\n          \"post_date\" : {\n            \"type\" : \"text\"\n          },\n          \"user\" : {\n            \"type\" : \"text\"\n          }\n        }\n      }\n    }\n  }\n}\n\n[elastic@node5 es_test]$ curl -X GET 'node5.big:9200\/twitter\/_settings\/?pretty'\n{\n  \"twitter\" : {\n    \"settings\" : {\n      \"index\" : {\n        \"creation_date\" : \"1534209219667\",\n        \"number_of_shards\" : \"2\",\n        \"number_of_replicas\" : \"1\",\n        \"uuid\" : \"-eN170knQYWVKRjZplPSVw\",\n        \"version\" : {\n          \"created\" : \"6020499\"\n        },\n        \"provided_name\" : \"twitter\"\n      }\n    }\n  }\n}\n<\/code><\/pre>\n<h2>geo_point<\/h2>\n<p>location \uc774\ub77c\ub294 \ud544\ub4dc\uc5d0 \uc218\uc9d1\ub418\ub294 \ub370\uc774\ud130\ub294 \uc88c\ud45c\uacc4 \uac12\uc774\ub2e4. kibana, visualize &gt; maps \uae30\ub2a5\uc5d0\uc11c \uc0ac\uc6a9\ud558\uae30 \uc704\ud574\uc11c\ub294 geo_point \ub77c\ub294 \ub370\uc774\ud130\ud0c0\uc785\uc73c\ub85c \uc218\uc9d1\ub418\uc5b4\uc57c \ud558\ubbc0\ub85c template \uc744 \uc0dd\uc131\ud574\uc11c \ud574\ub2f9 \ud544\ub4dc\uc5d0 \uc218\uc9d1\ub418\ub294 \ub370\uc774\ud130\ub294 text\uac00 \uc544\ub2cc geo_point \ub85c \ud30c\uc2f1\ud558\ub3c4\ub85d \uc124\uc815\ud560 \uc218 \uc788\ub2e4.<\/p>\n<pre><code class=\"bash\">curl -X PUT \"node5.big:9200\/_template\/template_accident\" -H 'Content-Type: application\/json' -d'\n{\n  \"template\" : \"accident*\",\n  \"mappings\" : {\n    \"accident\": {\n      \"properties\": {\n        \"location\": { \"type\": \"geo_point\" },\n        \"involvedCount\": { \"type\": \"double\" }\n      }\n    }\n  }\n}\n'\n<\/code><\/pre>\n<pre><code class=\"bash\">curl -X GET 'node5.big:9200\/_template\/template_accident?pretty'\n{\n  \"template_accident\" : {\n    \"order\" : 0,\n    \"index_patterns\" : [\n      \"accident*\"\n    ],\n    \"settings\" : { },\n    \"mappings\" : {\n      \"accident\" : {\n        \"properties\" : {\n          \"location\" : {\n            \"type\" : \"geo_point\"\n          },\n          \"involvedCount\" : {\n            \"type\" : \"double\"\n          }\n        }\n      }\n    },\n    \"aliases\" : { }\n  }\n}\n<\/code><\/pre>\n<h2>.monitoring-kibana<\/h2>\n<p>\uc544\ub798\uc758 <code>.monitoring-kibana<\/code> \ud15c\ud50c\ub9bf\uc740 kibana\uc758 x-pack \uc744 \ud65c\uc131\ud654\ud558\uba74\uc11c \uc0dd\uc131\ub41c \ud15c\ud50c\ub9bf\uc778\ub370 \uac01 \ud56d\ubaa9\ub4e4\uc744 \uc54c\uc544\ub450\uba74 \uc88b\uc744 \uac83 \uac19\ub2e4.<\/p>\n<pre><code class=\"bash\">[elastic@node5 ~]$ curl -X GET 'node5.big:9200\/_template\/.monitoring-kibana?pretty'\n{\n  \".monitoring-kibana\" : {\n    \"order\" : 0,\n    \"version\" : 6020099,\n    \"index_patterns\" : [\n      \".monitoring-kibana-6-*\"\n    ],\n    \"settings\" : {\n      \"index\" : {\n        \"format\" : \"6\",\n        \"codec\" : \"best_compression\",\n        \"number_of_shards\" : \"1\",\n        \"auto_expand_replicas\" : \"0-1\",\n        \"number_of_replicas\" : \"0\"\n      }\n    },\n    \"mappings\" : {\n      \"doc\" : {\n        \"dynamic\" : false,\n        \"properties\" : {\n          \"cluster_uuid\" : {\n            \"type\" : \"keyword\"\n          },\n          \"timestamp\" : {\n            \"type\" : \"date\",\n            \"format\" : \"date_time\"\n          },\n          \"interval_ms\" : {\n            \"type\" : \"long\"\n          },\n          \"type\" : {\n            \"type\" : \"keyword\"\n          },\n          \"source_node\" : {\n            \"properties\" : {\n              \"uuid\" : {\n                \"type\" : \"keyword\"\n              },\n              \"host\" : {\n                \"type\" : \"keyword\"\n              },\n              \"transport_address\" : {\n                \"type\" : \"keyword\"\n              },\n              \"ip\" : {\n                \"type\" : \"keyword\"\n              },\n              \"name\" : {\n                \"type\" : \"keyword\"\n              },\n              \"timestamp\" : {\n                \"type\" : \"date\",\n                \"format\" : \"date_time\"\n              }\n            }\n          },\n          \"kibana_stats\" : {\n            \"properties\" : {\n              \"kibana\" : {\n                \"properties\" : {\n                  \"uuid\" : {\n                    \"type\" : \"keyword\"\n                  },\n                  \"name\" : {\n                    \"type\" : \"keyword\"\n                  },\n                  \"host\" : {\n                    \"type\" : \"keyword\"\n                  },\n                  \"transport_address\" : {\n                    \"type\" : \"keyword\"\n                  },\n                  \"version\" : {\n                    \"type\" : \"keyword\"\n                  },\n                  \"snapshot\" : {\n                    \"type\" : \"boolean\"\n                  },\n                  \"status\" : {\n                    \"type\" : \"keyword\"\n                  },\n                  \"statuses\" : {\n                    \"properties\" : {\n                      \"name\" : {\n                        \"type\" : \"keyword\"\n                      },\n                      \"state\" : {\n                        \"type\" : \"keyword\"\n                      }\n                    }\n                  }\n                }\n              },\n              \"cloud\" : {\n                \"properties\" : {\n                  \"name\" : {\n                    \"type\" : \"keyword\"\n                  },\n                  \"id\" : {\n                    \"type\" : \"keyword\"\n                  },\n                  \"vm_type\" : {\n                    \"type\" : \"keyword\"\n                  },\n                  \"region\" : {\n                    \"type\" : \"keyword\"\n                  },\n                  \"zone\" : {\n                    \"type\" : \"keyword\"\n                  },\n                  \"metadata\" : {\n                    \"type\" : \"object\"\n                  }\n                }\n              },\n              \"os\" : {\n                \"properties\" : {\n                  \"load\" : {\n                    \"properties\" : {\n                      \"1m\" : {\n                        \"type\" : \"half_float\"\n                      },\n                      \"5m\" : {\n                        \"type\" : \"half_float\"\n                      },\n                      \"15m\" : {\n                        \"type\" : \"half_float\"\n                      }\n                    }\n                  },\n                  \"memory\" : {\n                    \"properties\" : {\n                      \"total_in_bytes\" : {\n                        \"type\" : \"float\"\n                      },\n                      \"free_in_bytes\" : {\n                        \"type\" : \"float\"\n                      },\n                      \"used_in_bytes\" : {\n                        \"type\" : \"float\"\n                      }\n                    }\n                  },\n                  \"uptime_in_millis\" : {\n                    \"type\" : \"long\"\n                  }\n                }\n              },\n              \"process\" : {\n                \"properties\" : {\n                  \"memory\" : {\n                    \"properties\" : {\n                      \"heap\" : {\n                        \"properties\" : {\n                          \"total_in_bytes\" : {\n                            \"type\" : \"float\"\n                          },\n                          \"used_in_bytes\" : {\n                            \"type\" : \"float\"\n                          },\n                          \"size_limit\" : {\n                            \"type\" : \"float\"\n                          }\n                        }\n                      },\n                      \"resident_set_size_in_bytes\" : {\n                        \"type\" : \"float\"\n                      }\n                    }\n                  },\n                  \"event_loop_delay\" : {\n                    \"type\" : \"float\"\n                  },\n                  \"uptime_in_millis\" : {\n                    \"type\" : \"long\"\n                  }\n                }\n              },\n              \"sockets\" : {\n                \"properties\" : {\n                  \"http\" : {\n                    \"properties\" : {\n                      \"total\" : {\n                        \"type\" : \"long\"\n                      }\n                    }\n                  },\n                  \"https\" : {\n                    \"properties\" : {\n                      \"total\" : {\n                        \"type\" : \"long\"\n                      }\n                    }\n                  }\n                }\n              },\n              \"timestamp\" : {\n                \"type\" : \"date\"\n              },\n              \"requests\" : {\n                \"properties\" : {\n                  \"disconnects\" : {\n                    \"type\" : \"long\"\n                  },\n                  \"total\" : {\n                    \"type\" : \"long\"\n                  },\n                  \"status_codes\" : {\n                    \"type\" : \"object\"\n                  }\n                }\n              },\n              \"response_times\" : {\n                \"properties\" : {\n                  \"average\" : {\n                    \"type\" : \"float\"\n                  },\n                  \"max\" : {\n                    \"type\" : \"float\"\n                  }\n                }\n              },\n              \"concurrent_connections\" : {\n                \"type\" : \"long\"\n              }\n            }\n          }\n        }\n      }\n    },\n    \"aliases\" : { }\n  }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>ElasticSearch Index templates Index template\uc740 \uc0c8\ub85c\uc6b4 index\uac00 \uc0dd\uc131\ub420 \ub54c\uc5d0, index \uc124\uc815 \ub610\ub294 \ud2b9\uc815 \ud544\ub4dc\uc758 \ub370\uc774\ud130 \ud0c0\uc785\uc744 \uc815\uc758\ud574\uc900\ub2e4. ElasticSearch\uc5d0 Logstash \ub4f1 \uc218\uc9d1\uae30\ub85c \ub370\uc774\ud130 \uc218\uc9d1 \uc804 index\uac00 \uc0ac\uc804 \uc0dd\uc131\ub420 \ud544\uc694\uac00 \uc5c6\ub2e4. \uadf8\ub7f0\ub370 \uadf8\ub0e5 \uc218\uc9d1\ud558\uba74 \uc22b\uc790\ub098 \ub0a0\uc9dc\ub294 \uc54c\uc544\uc11c \ud30c\uc2f1\uc744 \ud558\ub294\ub370 \ub098\uba38\uc9c0 \ub300\ubd80\ubd84\uc740 text\ub85c \ud574\uc11d\ud55c\ub2e4. index template\ub97c \uc0dd\uc131\ud568\uc73c\ub85c\uc368 index\ubcc4\ub85c Shard \uac2f\uc218\ub098 \ud2b9\uc815 \ud544\ub4dc\uc5d0 \ub300\ud55c \uac1c\ubcc4\uc801\uc778 \uad00\ub9ac\ub97c \ud560 \uc218 \uc788\ub2e4. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[25,145,144],"class_list":["post-336","post","type-post","status-publish","format-standard","hentry","category-elasticsearch","tag-elasticsearch","tag-template","tag-144"],"_links":{"self":[{"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/posts\/336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/comments?post=336"}],"version-history":[{"count":9,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/posts\/336\/revisions"}],"predecessor-version":[{"id":1250,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/posts\/336\/revisions\/1250"}],"wp:attachment":[{"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/media?parent=336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/categories?post=336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/tags?post=336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}