elasticsearch创建索引抛异常"error":{"type":"null_pointer_exception","reason":null}

出错

  • es集群,3个节点
  • 创建索引报错,空指针异常null_pointer_exception
  • 只有1个节点时正常,新增两个节点后报错
  • java程序调用elasticsearch批量更新方法返回信息:
{
     "index":{
     "_index":"cz_govb","_type":"160686340","_id":"205854415","status":500,"error":{
     "type":"null_pointer_exception","reason":null}}}
  • elasticsearch日志打印:
[2020-02-21T17:07:55,464][WARN ][o.e.a.b.TransportShardBulkAction] [node-1-master-003-9200] [[cz_gova][1]] failed to perform indices:data/write/bulk[s] on replica [cz_gova][1], node[OgETR1vZQwKcWOazjGj7XA], [R], s[STARTED], a[id=2jdIAqwjTeuHbZZa-8QU6A]
org.elasticsearch.transport.RemoteTransportException: [node-2-master-105-9200][10.150.8.105:9300][indices:data/write/bulk[s][r]]
Caused by: java.lang.NullPointerException
	at org.wltea.analyzer.dic.Dictionary.isStopWord(Dictionary.java:334) ~[?:?]
	at org.wltea.analyzer.core.AnalyzeContext.getNextLexeme(AnalyzeContext.java:316) ~[?:?]
	at org.wltea.analyzer.core.IKSegmenter.next(IKSegmenter.java:95) ~[?:?]
	at org.wltea.analyzer.lucene.IKTokenizer.incrementToken(IKTokenizer.java:88) ~[?:?]
	at org.apache.lucene.index.DefaultIndexingChain$PerField.invert(DefaultIndexingChain.java:746) ~[lucene-core-6.6.0.jar:6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:29:46]
	at org.apache.lucene.index.DefaultIndexingChain.processField(DefaultIndexingChain.java:447) ~[lucene-core-6.6.0.jar:6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:29:46]
	at org.apache.lucene.index.DefaultIndexingChain.processDocument(DefaultIndexingChain.java:403) ~[lucene-core-6.6.0.jar:6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:29:46]
	at org.apache.lucene.index.DocumentsWriterPerThread.updateDocument(DocumentsWriterPerThread.java:232) ~[lucene-core-6.6.0.jar:6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:29:46]
	at org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:478) ~[lucene-core-6.6.0.jar:6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:29:46]
	at org.apache.lucene.index.IndexWriter.updateDocument(IndexWriter.java:1571) ~[lucene-core-6.6.0.jar:6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:29:46]
	at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1316) ~[lucene-core-6.6.0.jar:6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:29:46]
	at org.elasticsearch.index.engine.InternalEngine.index(InternalEngine.java:663) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.index.engine.InternalEngine.indexIntoLucene(InternalEngine.java:607) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.index.engine.InternalEngine.index(InternalEngine.java:505) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.index.shard.IndexShard.index(IndexShard.java:556) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.index.shard.IndexShard.index(IndexShard.java:545) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.action.bulk.TransportShardBulkAction.executeIndexRequestOnReplica(TransportShardBulkAction.java:441) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnReplica(TransportShardBulkAction.java:376) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnReplica(TransportShardBulkAction.java:69) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.action.support.replication.TransportReplicationAction$AsyncReplicaAction.onResponse(TransportReplicationAction.java:494) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.action.support.replication.TransportReplicationAction$AsyncReplicaAction.onResponse(TransportReplicationAction.java:467) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.index.shard.IndexShardOperationsLock.acquire(IndexShardOperationsLock.java:151) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.index.shard.IndexShard.acquireReplicaOperationLock(IndexShard.java:1673) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.action.support.replication.TransportReplicationAction$AsyncReplicaAction.doRun(TransportReplicationAction.java:566) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.action.support.replication.TransportReplicationAction$ReplicaOperationTransportHandler.messageReceived(TransportReplicationAction.java:451) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.action.support.replication.TransportReplicationAction$ReplicaOperationTransportHandler.messageReceived(TransportReplicationAction.java:441) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.transport.TcpTransport$RequestHandler.doRun(TcpTransport.java:1544) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:638) ~[elasticsearch-5.5.2.jar:5.5.2]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-5.5.2.jar:5.5.2]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_161]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_161]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]

原因

  • 根据接口返回信息,只能看到空指针异常,看不到具体报错信息,必须查看其它日志信息
  • 查看了es日志,发现创建索引使用分词器报的错(IKTokenizer.incrementToken
  • 使用 ./bin/elasticsearch-plugin list命令,发现插件已正常安装,继续排错
  • 又仔细看了es日志,发现是分词器文件问题(NullPointerException: null at org.wltea.analyzer.dic.Dictionary.isStopWord(Dictionary.java:334))初步怀疑缺少dic文件
  • 查看了下,发现确实少了一个文件夹。新来的运维不熟悉elasticsearch,安装分词器插件时,是从第一个节点拷贝的,又没有拷贝完全,遗漏了一个文件夹

解决

  • 关闭es节点1,把config下的文件夹复制出来,放到节点2,3对应位置,重启生效
    在这里插入图片描述

你可能感兴趣的:(异常报错,elasticsearch,java,nullexception,创建索引报空指针)