elasticsearch自定义插件

2020-06-01 00:00:00 函数 文件 自定义 插件 希望

一直想尝试自己造轮子,毕竟用了header,smartcn等插件,也很好奇es插件如何自定义。

搞了好几天,今天终于成功了,虽然只是一个hello world,但基本的流程,我相关的java类我大致搞清楚了,再次纪录一下。


es官网找到了一个链接:Writing an Elasticsearch Plugin: Getting Started,让人失望透顶,es的版本不一的情况下,我2.3.1es版本,根本没有org.elasticsearch.plugins.AbstractPlugin,

没办法继续碰壁,网上千篇一律的抄来抄去,让人厌恶。

只能继续深耕es官网文档。Help for plugin authors,


先得到一个基本的插件框架。1:如果时网页插件,必需包含

  • The plugin-descriptor.properties file
  • The _site/ directory
  • The _site/index.html file

2:非site插件,必需包含

The plugin-descriptor.properties file

和java类文件。

基本的plugin-descriptor.properties,

description=hello - A web front end for an elastic search cluster
version=master
name=hello

version=2.3.1

### mandatory elements for site plugins:
#
# 'site': set to true to indicate contents of the _site/
#  directory in the root of the plugin should be served.
site=false
#
### mandatory elements for jvm plugins :
#
# 'jvm': true if the 'classname' class should be loaded
#  from jar files in the root directory of the plugin.
#  Note that only jar files in the root directory are
#  added to the classpath for the plugin! If you need
#  other resources, package them into a resources jar.
jvm=true
#
# 'classname': the name of the class to load, fully-qualified.
classname=${elasticsearch.plugin.classname}
#
# 'java.version' version of java the code is built against
# use the system property java.specification.version
# version string must be a sequence of nonnegative decimal integers
# separated by "."'s and may have leading zeros
java.version=1.7
#
# 'elasticsearch.version' version of elasticsearch compiled against
# You will have to release a new version of the plugin for each new
# elasticsearch release. This version is checked when the plugin
# is loaded so Elasticsearch will refuse to start in the presence of
# plugins with the incorrect elasticsearch.version.
elasticsearch.version=2.3.1
#
### deprecated elements for jvm plugins :
#
# 'isolated': true if the plugin should have its own classloader.
# passing false is deprecated, and only intended to support plugins 
# that have hard dependencies against each other. If this is
# not specified, then the plugin is isolated by default.
#isolated=true

相关文章