아빠는 개발자

[es] Elasticsearch Plugin 8.4.1 본문

Elastic

[es] Elasticsearch Plugin 8.4.1

father6019 2023. 9. 4. 23:14
728x90
반응형

Elasticsearch 8.4 Plugin Build & Install TEST

 

작업 요약

  • github.com (https://github.com/elastic/elasticsearch.git) 에서 elasticsearch 소스 다운로드
  • 소스에서 plugin > example >  rest-handler  복사
  • build.gradle 수정 및 plugin 빌드
  • elasticsearch 에 빌드한 플러그인 설치 - docker compose 
  • 테스트

1. elasticsearch  project source code  download - https://github.com/elastic/elasticsearch.git 

$ cd plugin
$ git clone https://github.com/elastic/elasticsearch.git

#git branch  (로컬 브랜치 목록 조회)
#git branch -r  (원격 브랜치 목록 조회)
#git branch -a  (모든 브랜치 목록 조회)

$ cd elasticsearch && git checkout 8.4

/Users/doo/build-tools-internal/version.properties (No such file or directory)

 

2. copy plugin example – rest-handler

$ cp -r plugins/examples/rest-handler ~/plugin
$ cp -r gradle* ~/plugin/rest-handler/
$ cd ~/plugin

3. edit build.gradle and build

buildscript {
  repositories {
    mavenLocal()
    mavenCentral()
//    jcenter()
  }

  dependencies {
    classpath "org.elasticsearch.gradle:build-tools:8.4.1"
  }
}

plugins {
  id 'java'
}

/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0 and the Server Side Public License, v 1; you may not use this file except
 * in compliance with, at your election, the Elastic License 2.0 or the Server
 * Side Public License, v 1.
 */
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.yaml-rest-test'



esplugin {
  name 'rest-handler'
  description 'An example plugin showing how to register a REST handler'
  classname 'org.elasticsearch.example.resthandler.ExampleRestHandlerPlugin'
  licenseFile rootProject.file('SSPL-1.0+ELASTIC-LICENSE-2.0.txt')
  noticeFile rootProject.file('NOTICE.txt')
}

group = 'com.example'
version = '0.1'
sourceCompatibility = '18'

repositories {
  mavenCentral()
//  jcenter()
}


dependencies {
  implementation group: 'org.elasticsearch', name: 'elasticsearch', version: '8.4.1'
//  yamlRestTestRuntimeOnly "org.apache.logging.log4j:log4j-core:${log4jVersion}"

  testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.7.0'
  testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.7.0'


}

test {
  useJUnitPlatform()
}

 

(base) ➜  rest-handler ./gradlew clean assemble
(base) ➜  rest-handler cp -af build/distributions/rest-handler-0.1.zip ~/docker/900gle-elk/elasticsearch/plugin

 

참고

$ ./gradlew test yamlRestTest --warning-mode all
$ ./gradlew test javaRestTest --warning-mode all
$ ./gradlew assemble --warning-mode all

// output to build/distribtions/rest-handler.zip

4. elasticsearch plugin install

Dockerfile

ARG ELASTIC_VERSION

FROM docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION}




COPY config/stopFilter.txt config/stopFilter.txt
COPY config/synonymsFilter.txt config/synonymsFilter.txt
COPY config/user_dictionary.txt config/user_dictionary.txt


COPY plugin/kr-danalyzer-8.4.1.zip plugin/kr-danalyzer-8.4.1.zip
COPY plugin/rest-handler-0.1.zip plugin/rest-handler-0.1.zip


RUN elasticsearch-plugin install analysis-nori

RUN elasticsearch-plugin install file:///usr/share/elasticsearch/plugin/kr-danalyzer-8.4.1.zip
RUN elasticsearch-plugin install file:///usr/share/elasticsearch/plugin/rest-handler-0.1.zip

 

docker 실행 

#실행
(base) ➜  900gle-elk git:(8.4.1) ✗ docker compose up -d --build

#확인
(base) ➜  900gle-elk git:(8.4.1) ✗ docker ps -a

로그확인 

(base) ➜  900gle-elk git:(8.4.1) ✗ docker logs 900gle-elk-elasticsearch-1

 

5. Test

// start elasticsearch
$ ./bin/elasticsearch

http://localhost:9200/_cat/example

 

728x90
반응형

'Elastic' 카테고리의 다른 글

[es] Search API response 구조  (0) 2024.05.05
[es8] elasticsearch stable-esplugin  (0) 2023.09.04