在 Mapping 里面,将 dynamic 参数设置成 strict 可以拒绝索引包含未知字段的文档。 此条 Tips 由 medcl 贡献。

Elasticsearch的module中可以使用plugin中的jar么

Elasticsearch | 作者 ridethewind | 发布于2018年09月04日 | 阅读数:2288

由于业务需要自己写了一个module,目前有这么一个需求,在这个module中调用一个plugin中的方法.在不移动jar包的前提下有什么方法可以在module中加载到plugin中的jar吗?
已邀请:

rochy - rochy_he

赞同来自: ridethewind

你这个需求其实与ES关系就不是很大了,注意就是jar包动态加载的需求;
关于jar包动态加载并调用其内部方法,可以参考下面的文章:
https://blog.csdn.net/wawmg/ar ... 61815
https://blog.csdn.net/chenleix ... 07971
 
ES插件中可以通过下面的代码获取当前plugin的目录:
public Path getConfigFilePath() {
return PathUtils
.get(new File(AnalysisHanLPPlugin.class.getProtectionDomain().getCodeSource().getLocation().getPath())
.getParent())
.toAbsolutePath();
}

rochy - rochy_he

赞同来自:

如果这个plugin注册了 restful 的接口 (Rest handler),那么就可以通过接口来进行方法调用
 
注册 Rest handler 插件的样例:https://github.com/elastic/ela ... ndler
 
 

要回复问题请先登录注册