{"id":6058,"date":"2022-08-19T18:26:29","date_gmt":"2022-08-19T09:26:29","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6058"},"modified":"2022-08-20T18:13:42","modified_gmt":"2022-08-20T09:13:42","slug":"elasticsearch-7-x-plugin-%eb%a7%8c%eb%93%a4%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6058","title":{"rendered":"Elasticsearch 7.x plugin \ub9cc\ub4e4\uae30"},"content":{"rendered":"<h1>Elasticsearch 7.x plugin \ub9cc\ub4e4\uae30<\/h1>\n<h2>Elasticsearch \uc18c\uc2a4 \ub2e4\uc6b4\ub85c\ub4dc<\/h2>\n<pre><code class=\"language-bash\">mkdir \/tmp\/work\ncd \/tmp\/work\ngit clone https:\/\/github.com\/elastic\/elasticsearch.git\ncd elasticsearch<\/code><\/pre>\n<p>\uc124\uce58\ud558\ub824\ub294 \uc11c\ubc84 \ubc84\uc804\uc5d0 \ub9de\ucdb0\uc11c checkout \ud55c\ub2e4.<\/p>\n<pre><code class=\"language-bash\">git checkout 7.15<\/code><\/pre>\n<h2>\uc608\uc81c \ubcc4\ub3c4 \ubcf5\uc0ac<\/h2>\n<pre><code class=\"language-bash\">cp -r plugins\/examples\/rest-handler ..\/\ncp -r gradle* ..\/rest-handler\/\ncd ..\/rest-handler\/<\/code><\/pre>\n<h2>build.gradle<\/h2>\n<p>gradle 7.x \ubc84\uc804\uc5d0\uc11c \ucef4\ud30c\uc77c\ub418\uc5c8\ub2e4.<\/p>\n<pre><code class=\"language-gradle\">apply plugin: &#039;java&#039;\napply plugin: &#039;maven-publish&#039;\n\nsourceCompatibility = 1.8\ncompileJava.options.encoding = &#039;UTF-8&#039;\n\nversion = &#039;7.15.1&#039;\njar {\n  manifest {\n    attributes &#039;Implementation-Title&#039;: &#039;Example rest handler Plugin&#039;,\n            &#039;Implementation-Version&#039;: archiveVersion\n  }\n}\n\nrepositories {\n  mavenCentral()\n}\n\ndependencies {\n  implementation group: &#039;commons-collections&#039;, name: &#039;commons-collections&#039;, version: &#039;3.2&#039;\n  implementation group: &#039;org.elasticsearch&#039;, name: &#039;elasticsearch&#039;, version: version\n  implementation group: &#039;org.apache.logging.log4j&#039;, name: &#039;log4j-api&#039;, version: &#039;2.11.0&#039;\n  implementation group: &#039;org.apache.logging.log4j&#039;, name: &#039;log4j-core&#039;, version: &#039;2.11.0&#039;\n  testImplementation group: &#039;junit&#039;, name: &#039;junit&#039;, version: &#039;4.+&#039;\n  implementation group: &#039;org.slf4j&#039;, name: &#039;slf4j-api&#039;, version: &#039;1.7.25&#039;\n}\n\ntest {\n  systemProperties &#039;property&#039;: &#039;value&#039;\n}\n\npublishing {\n  repositories {\n    flatDir {\n      dirs &#039;repos&#039;\n    }\n  }\n}\n\ntask buildPluginZip(type: Zip, dependsOn:[&#039;:jar&#039;]) {\n  archiveBaseName = &#039;example-rest-handler-plugin&#039;\n  classifier = &#039;plugin&#039;\n  from &#039;build\/libs&#039;\n  from &#039;src\/main\/resources&#039;\n}\n\nartifacts {\n  archives buildPluginZip\n}\n\n[ compileJava, compileTestJava ]*.options*.encoding = &#039;UTF-8&#039;\n[ compileJava, compileTestJava ]*.options*.compilerArgs = [&#039;-Xlint:-options&#039;]<\/code><\/pre>\n<h2>plugin-descriptor.properties<\/h2>\n<p>classname \uc740 ExampleRestHandlerPlugin.java \uc758 \ud328\ud0a4\uc9c0\uba85\uacfc \uc77c\uce58\ud574\uc57c \ud55c\ub2e4.<\/p>\n<pre><code class=\"language-bash\">mkdir src\/main\/resources\nvi src\/main\/resources\/plugin-descriptor.properties\n\ndescription=Example rest handler Plugin\nversion=7.15.1\nname=example-rest-handler-plugin\nclassname=org.elasticsearch.example.resthandler.ExampleRestHandlerPlugin\njava.version=1.8\nelasticsearch.version=7.15.1<\/code><\/pre>\n<h2>build<\/h2>\n<pre><code class=\"language-bash\">.\/gradlew clean\n.\/gradlew buildPluginZip\n\nls -al build\/distributions\/<\/code><\/pre>\n<h2>install plugin<\/h2>\n<p><code>file:\/\/\/<\/code> \uc640 \uac19\uc774 <code>\/<\/code> \uac00 3\uac1c\uc5ec\uc57c \ud55c\ub2e4.<\/p>\n<pre><code class=\"language-bash\">.\/bin\/elasticsearch-plugin install file:\/\/\/home\/...\/example-rest-handler-plugin-7.15.1-plugin.zip<\/code><\/pre>\n<h2>test<\/h2>\n<pre><code class=\"language-bash\">\/\/ start elasticsearch\n$ .\/bin\/elasticsearch\n$ curl 127.0.0.1:9200\/_cat\/example<\/code><\/pre>\n<h2>docker \ub85c elasticsearch \ub97c \uc2e4\ud589\ud55c \uacbd\uc6b0<\/h2>\n<pre><code class=\"language-bash\">mkdir ..\/dockerize\ncp build\/distributions\/example-rest-handler-plugin-7.15.1-plugin.zip ..\/dockerize\/<\/code><\/pre>\n<pre><code class=\"language-bash\">cd ..\/dockerize\n\nvi Dockerfile\n--------------\nFROM docker.elastic.co\/elasticsearch\/elasticsearch:7.15.1\n\nADD example-rest-handler-plugin-7.15.1-plugin.zip \/\n\nRUN \/usr\/share\/elasticsearch\/bin\/elasticsearch-plugin install --batch file:\/\/\/example-rest-handler-plugin-7.15.1-plugin.zip\n--------------<\/code><\/pre>\n<pre><code class=\"language-bash\">docker build -t skyer9\/elasticsearch-with-plugin:7.15.1 .<\/code><\/pre>\n<pre><code class=\"language-bash\">docker login\ndocker push skyer9\/elasticsearch-with-plugin:7.15.1<\/code><\/pre>\n<p><a href=\"http:\/\/localhost:9200\/_cat\/example\">http:\/\/localhost:9200\/_cat\/example<\/a> \uc5d0 \uc811\uc18d\ud55c\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Elasticsearch 7.x plugin \ub9cc\ub4e4\uae30 Elasticsearch \uc18c\uc2a4 \ub2e4\uc6b4\ub85c\ub4dc mkdir \/tmp\/work cd \/tmp\/work git clone https:\/\/github.com\/elastic\/elasticsearch.git cd elasticsearch \uc124\uce58\ud558\ub824\ub294 \uc11c\ubc84 \ubc84\uc804\uc5d0 \ub9de\ucdb0\uc11c checkout \ud55c\ub2e4. git checkout 7.15 \uc608\uc81c \ubcc4\ub3c4 \ubcf5\uc0ac cp -r plugins\/examples\/rest-handler ..\/ cp -r gradle* ..\/rest-handler\/ cd ..\/rest-handler\/ build.gradle gradle 7.x \ubc84\uc804\uc5d0\uc11c \ucef4\ud30c\uc77c\ub418\uc5c8\ub2e4. apply plugin: &#039;java&#039; apply plugin: &#039;maven-publish&#039; sourceCompatibility = 1.8 compileJava.options.encoding = &#039;UTF-8&#039;\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6058\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-6058","post","type-post","status-publish","format-standard","hentry","category-elasticsearch"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6058","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6058"}],"version-history":[{"count":15,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6058\/revisions"}],"predecessor-version":[{"id":6081,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6058\/revisions\/6081"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}