不要急,总有办法的

多个geo point的业务

回复

Elasticsearch匿名用户 发起了问题 • 1 人关注 • 0 个回复 • 1974 次浏览 • 2017-10-29 07:36 • 来自相关话题

包含geoshape的文档,index太慢的问题

Elasticsearchxlp 回复了问题 • 2 人关注 • 2 个回复 • 2322 次浏览 • 2020-08-27 09:25 • 来自相关话题

Logstash中input File可多级文件夹下读取log文件怎么读取不了啊

Logstashtacsklet 回复了问题 • 2 人关注 • 1 个回复 • 5600 次浏览 • 2017-10-30 08:47 • 来自相关话题

请问下谁能详细讲解下es5的几种缓存。

回复

Elasticsearchmhl 发起了问题 • 4 人关注 • 0 个回复 • 2660 次浏览 • 2017-10-28 11:39 • 来自相关话题

社区日报 第83期 (2017-10-28)

社区日报白衬衣 发表了文章 • 0 个评论 • 1981 次浏览 • 2017-10-28 10:57 • 来自相关话题

1.ES选举-类Bully算法
http://t.cn/RWWD6LM
2.如何更优雅的定制开发elasicsearch插件
https://elasticsearch.cn/article/339
3.你应该了解的5个 Logstash Filter 插件
https://elasticsearch.cn/article/332
活动预告:Elastic 长沙交流会 
https://elasticsearch.cn/article/320

感谢jiangtao,dongne的投稿。
编辑:金桥
归档:https://elasticsearch.cn/article/341
订阅:https://tinyletter.com/elastic-daily

elasticsearch应用开发案例

回复

ElasticsearchsoochowLeo 发起了问题 • 1 人关注 • 0 个回复 • 3831 次浏览 • 2017-10-27 17:14 • 来自相关话题

XContentBuilder 通过for循环执行,创建索引mappin结构

Elasticsearchlrc 回复了问题 • 2 人关注 • 2 个回复 • 18172 次浏览 • 2018-01-12 09:27 • 来自相关话题

elasticsearch与spring整合启动报错

Elasticsearchfeihui 回复了问题 • 2 人关注 • 1 个回复 • 2250 次浏览 • 2017-10-30 08:06 • 来自相关话题

kibana安装marvel插件报错,什么原因?错误如图

KibanaEric_L 回复了问题 • 2 人关注 • 1 个回复 • 2659 次浏览 • 2017-10-30 14:28 • 来自相关话题

谁知道hbase数据怎么同步到es

回复

Elasticsearchhelloword 发起了问题 • 2 人关注 • 0 个回复 • 4439 次浏览 • 2017-10-27 11:28 • 来自相关话题

大批量的index请求走的是bulk api 不是index api

Elasticsearchkennywu76 回复了问题 • 2 人关注 • 1 个回复 • 3519 次浏览 • 2017-10-27 12:12 • 来自相关话题

elasticsearch的java客户端启动CPU负载飙高到几万

Elasticsearchkennywu76 回复了问题 • 4 人关注 • 2 个回复 • 4123 次浏览 • 2018-01-02 14:13 • 来自相关话题

社区日报 第82期 (2017-10-27)

社区日报laoyang360 发表了文章 • 0 个评论 • 2057 次浏览 • 2017-10-27 06:36 • 来自相关话题

1、基于HBase+ ElasticSearch的车联网的应用
http://t.cn/RWoD1x8 
2、携程大数据实践:高并发应用架构及推荐系统案例
http://t.cn/RWoDFX8 
3、Elasticsearch相关度计算原理
http://t.cn/RWK4SQN 
4、搞清楚logstash、filebeat到底什么区别?
http://t.cn/RWKPDDj 

编辑:laoyang360
归档:https://elasticsearch.cn/article/340
订阅:https://tinyletter.com/elastic-daily 

 

如何更优雅的定制开发elasicsearch插件

Elasticsearchjiangtao 发表了文章 • 2 个评论 • 6343 次浏览 • 2017-10-26 21:06 • 来自相关话题

一,何为优雅:
    在此需要感谢@Medcl,开发了ik,mmseg等为elasticsearch的分词插件,使我们能够比较容易的上手并应用elasticsearch。
   但是我们如果要对插件进行二次定制,或者重新开发一个插件呢。按照官网教程,每次都得打包、替换、重启,这是一个很不方便的过程,固然可以通过testCase来做debug,但是所见即所得的编码习惯,直接上手debug,才是最高效的方式。
   介绍插件开发的博客何其多,个人私以为都没有get到G点,其实深入研究下elasticsearch源码,fix 这个问题并不难,下面希望通过这篇文章帮助到大家。
二,elasticsearch插件的加载机制
①:Node节点启动过程,Elasticsearch.java会调用Bootstrap.java中的init函数。
static void init(...)  {
...
INSTANCE = new Bootstrap();
INSTANCE.setup(true, environment);
...
INSTANCE.start();
}
②:Node节点通过setup方法进行实例化。
 private void setup(boolean addShutdownHook, Environment environment) throws BootstrapException {

node = new Node(environment) {

...
}
③:Node.java类中会包含各类的service服务,其中包括PluginsService服务。在实例化PluginsService服务时会传参
environment.pluginsFile(),classpathPlugins等参数。而pluginsFile()即是elasticsearch所指定的plugin目录,elasticsearch会扫描该路径下所有的插件,并加载进来。
public Node(Environment environment) {
this(environment, Collections.emptyList());
}

protected Node(final Environment environment, Collection<Class<? extends Plugin>> classpathPlugins) {
...
this.pluginsService = new PluginsService(tmpSettings, environment.modulesFile(), environment.pluginsFile(), classpathPlugins);
...
}
④classpathPlugins参数介绍:
public Node(Environment environment) {
this(environment, Collections.emptyList());
}
在elasticsearch源码中,这个参数Collection<Class<? extends Plugin>> classpathPlugins一直都是空集合。
没有任何地方注入修改该参数。elasticsearch不但会扫描插件所在路径中的插件,同样也会加载classpathPlugins中所指定的插件,只不过问题是elasticsearch没有给我们提供相应的参数!!!!
三,如何更优雅的开发开发插件
    接上一段小节④,我们只要利用classpathPlugins该参数,就可以在elasticsearch源码环境中进行debug了!!!
    我的实现思路如下,通过继承Node.java,并重写Node类的构造方法,然后在bootstrap中直接实例化该子类,便可以通过elasticsearch直接bug 插件源码了。
   下面贴出我的实现代码,供大家参考:
/**
* Created by jiangtao on 2017/07/30.
*/

import org.elasticsearch.Version;
import org.elasticsearch.env.Environment;
import org.elasticsearch.node.Node;
import org.elasticsearch.plugins.Plugin;

import java.util.Collection;

public class EmbeddedNode extends Node {

private Version version;
private Collection<Class<? extends Plugin>> plugins;

public EmbeddedNode(Environment environment, Version version, Collection<Class<? extends Plugin>> classpathPlugins) {
super(environment, classpathPlugins);
this.version = version;
this.plugins = classpathPlugins;
}

public Collection<Class<? extends Plugin>> getPlugins() {
return plugins;
}

public Version getVersion() {
return version;
}
}
    private void setup(boolean addShutdownHook, Environment environment) throws BootstrapException {
.....
//注释Node初始化源码
/* node = new Node(environment) {
@Override
protected void validateNodeBeforeAcceptingRequests(
final Settings settings,
final BoundTransportAddress boundTransportAddress, List<BootstrapCheck> checks) throws NodeValidationException {
BootstrapChecks.check(settings, boundTransportAddress, checks);
}
};*/

Collection plugins = new ArrayList<>();
Collections.addAll(plugins, AnalysisIkPlugin.class, HelloPlugin.class, AnalysisMMsegPlugin.class);//, ,AnalysisMMsegPlugin.class
node = new EmbeddedNode(environment, Version.CURRENT, plugins) {
@Override
protected void validateNodeBeforeAcceptingRequests(final Settings settings, final BoundTransportAddress boundTransportAddress, List<BootstrapCheck> checks) throws NodeValidationException {
BootstrapChecks.check(settings, boundTransportAddress, checks);
}
};
}

 
四,部署插件相关的注意事项:
     有关插件开发的详细配置,es插件的种类,在此不再赘述,具体可参考官方文档,更权威,更直接。
下面贴个图,本人在elasticsearch中同时整合了多个插件,以供学习研究时用,直接debug,个人感觉十分不错。

插件.png

 

【环境篇】Intellij Idea编译Elasticsearch源码

Elasticsearchjiangtao 发表了文章 • 0 个评论 • 11044 次浏览 • 2017-10-26 19:58 • 来自相关话题

一、软件环境
Intellij Idea:2017.1版本
Elasticsearch源码版本:5.3.1
JDK:1.8.0_111 
Gradle :建议3.3及以上版本。官网:https://gradle.org/
二、下载Elasticsearch源码
到github clone源码,https://github.com/elastic/elasticsearch.git,建议选择稳定版本分支。

三、导入idea
1,编译执行gradle build.gradle,报错:
you must run gradle idea from the root of elasticsearch before importing into intellij
解决办法:运行命令:gradle idea。同理如使用eclipse编译器,运行gradle eclipse。该过程会向mvn仓库下载响应的jar包,视网络情况,大概会持续20分钟。

 
2,运行org.elasticsearch.bootstrap.Elasticsearch 方法,报错:
"path.home is not configured" when starting ES in transport and client mode“,
解决办法:在VM options中加入配置:-Des.path.home=/home/jiangtao/code/elasticsearch/core,即指向相应的core模块的路径。

3,报错:org.elasticsearch.bootstrap.BootstrapException: java.nio.file.NoSuchFileException
  
Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.nio.file.NoSuchFileException: /home/jiangtao/code/elasticsearch/core/config Likely root cause: java.nio.file.NoSuchFileException: /home/jiangtao/code/elasticsearch/core/config
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
at java.nio.file.Files.readAttributes(Files.java:1737)
at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
at java.nio.file.Files.walkFileTree(Files.java:2662)

解决办法:将distribution模块src路径下的config整个文件copy到core模块中

4,报错: ERROR Could not register mbeans java.security.AccessControlException
2017-06-06 09:52:08,007 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:585)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1848)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:322)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
........
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84)

       解决办法:禁用jmx,在VM options中继续添加配置:  -Dlog4j2.disable.jmx=true。注意:在VM options中多个配置中间用空格分隔。

5,报错: java.lang.IllegalStateException: Unsupported transport.type
错误栈如下:
[2017-06-06T10:04:21,327][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler]  uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: Unsupported transport.type
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:127) ~[main/:?]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) ~[main/:?]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:58) ~[main/:?]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[main/:?]
at org.elasticsearch.cli.Command.main(Command.java:88) ~[main/:?]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[main/:?]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[main/:?]
Caused by: java.lang.IllegalStateException: Unsupported transport.type
at org.elasticsearch.common.network.NetworkModule.getTransportSupplier(NetworkModule.java:213) ~[main/:?]
at org.elasticsearch.node.Node.<init>(Node.java:421) ~[main/:?]
at org.elasticsearch.node.Node.<init>(Node.java:242) ~[main/:?]
at org.elasticsearch.bootstrap.Bootstrap$6.<init>(Bootstrap.java:242) ~[main/:?]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:242) ~[main/:?]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:360) ~[main/:?]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) ~[main/:?]
... 6 more

这个是由于依赖的transport等jar并没有找到,可以在项目根目录找到models模块,然后将下面目录打包,然后copy到distribution/src/main/models目录下,
也可以直接去官网(https://www.elastic.co/downloads/elasticsearch)下载zip包,解压后直接copy。
我直接去官网下载的zip包:从官网下载完毕zip包后,具体解决办法请看:错误 6。


6,copy module版本冲突
错误栈如下: 
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: Plugin [lang-expression] is incompatible with Elasticsearch [5.3.4]. Was designed for version [5.3.1]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:127) ~[main/:?]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) ~[main/:?]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:58) ~[main/:?]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[main/:?]
at org.elasticsearch.cli.Command.main(Command.java:88) ~[main/:?]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[main/:?]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[main/:?]
Caused by: java.lang.IllegalArgumentException: Plugin [lang-expression] is incompatible with Elasticsearch [5.3.4]. Was designed for version [5.3.1]

解决办法:修改es当前版本
将core模块中的Version.java类由
public static final Version CURRENT = V_5_3_4_UNRELEASED;
修改为:
public static final Version CURRENT = V_5_3_1;