Elasticsearch:No handler for type [string]...与Rejecting mapping update to [hn] as the final mapping would have more than 1 type异常处理

报错原因

我的Elasticsearch是"6.4.0"版本,当我创建字段时

{
"domain":
        {
    "type": "string",
    "index": "not_analyzed"
    }
}

原因分析

查看官方文档后发现是在新版本中已经移除该操作方式了

Elasticsearch从5.X就引入了textkeyword,其中keyword适用于不分词字段,搜索时只能完全匹配,这时string还保留着。 
到了6.X就彻底移除string了。 
另外,"index"的值只能是boolean变量了。

解决方法

修改为

    {
    "domain":{
                    "type":"text",
                    "index":"false"
                },
    }        

出现的第二个问题

1. 此时抛出了另外一个error

            {
                "type": "illegal_argument_exception",
                "reason": "Rejecting mapping update to [hn] as the final mapping would have more than 1 type: [poll, job, story]"
            }

2. 这个异常引发的原因同样是版本问题

  
  在Elasticsearch 6.0.0或更高版本中创建的索引可能只包含单个mapping type
在具有多种映射类型的5.x中创建的索引将继续像以前一样在Elasticsearch 6.x中运行。映射类型将在Elasticsearch 7.0.0中完全删除。

原文地址:https://www.cnblogs.com/tcppdu/p/9598121.html