Elasticsearch null

Elasticsearch null,第1张

Elasticsearch null 一、系统环境 组件版本ElasticSearch6.6.1

ES有6个节点,简称es1、es2、es3、es4、es5、es6

二、问题复现 1、ES索引
{
  "mappings": {
    "_doc": {
      "dynamic": "strict",
      "properties": {
        "title": {
          "type": "text",
          "analyzer": "ik_max_word"
        }
      }
    }
  },
  "settings": {
    "number_of_replicas": 1,
    "number_of_shards": 5
  }
}
2、插入数据
{
  "title":"测试用例"
}
3、ES报错null_pointer_exception

ES插入数据时,有些时候返回错误,有些时候正常

{
  "error": {
    "root_cause": [
      {
        "type": "null_pointer_exception",
        "reason": null
      }
    ],
    "type": "null_pointer_exception",
    "reason": null
  },
  "status": 500
}
三、问题分析

null_pointer_exception是由于ES部分节点没有ik分词器返回错误,如:只有es1上有ik分词器
因而当数据随机落在节点es1上时,正常插入,其他节点均失败

# 验证机器是否安装ik分词器方法,记得修改成你的IP地址和端口号
curl -XGET "http://192.168.1.1:9200/_analyze" -H 'Content-Type: application/json' -d'
{
  "analyzer": "ik_max_word",
  "text": "我安装了分词器"
}'

# 成功则返回分词结果,失败则返回Error
四、解决方法
// 移动分片到指定的节点
POST /_cluster/reroute
{
    "commands" : [ {
        "move" : 
            {
              "index" : "索引名",
              "shard" : 4, 
              "from_node" : "节点名", 
              "to_node" : "节点名"
            }
        }
    ]
}
参考鸣谢

ES指定分片移动到指定的节点

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5688879.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存