[923]ElasticSearch 7.4.2 Root mapping definition has unsupported parameters

2020-12-29 10:40:52 浏览数 (1)

新建索引

  • 分片设置
    • number_of_shards 每个索引的主分片数,默认值是 5 。这个配置在索引创建后不能修改。
    • number_of_replicas 每个主分片的副本数,默认值是 1 。对于活动的索引库,这个配置可以随时修改。
代码语言:javascript复制
PUT /test2
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 0
  },
  "mappings": {
    "user":{
      "properties":{
        "id":{
          "type":"long"
        },
        "title":{
          "type":"text",
          "analyzer":"ik_max_word"
        },
        "content":{
          "type":"text",
          "analyzer":"ik_max_word"
        },
        "postdate":{
          "type":"date"
        },
        "url":{
          "type":"text"
        }
      }
    }
  }
}

然后报错,Root mapping definition has unsupported parameters

代码语言:javascript复制
{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Root mapping definition has unsupported parameters:  [user : {properties={postdate={type=date}, id={type=long}, title={analyzer=ik_max_word, type=text}, content={analyzer=ik_max_word, type=text}, url={type=text}}}]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [user : {properties={postdate={type=date}, id={type=long}, title={analyzer=ik_max_word, type=text}, content={analyzer=ik_max_word, type=text}, url={type=text}}}]",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "Root mapping definition has unsupported parameters:  [user : {properties={postdate={type=date}, id={type=long}, title={analyzer=ik_max_word, type=text}, content={analyzer=ik_max_word, type=text}, url={type=text}}}]"
    }
  },
  "status": 400
}

查看官网示例后发现 7.4 默认不在支持指定索引类型,默认索引类型是_doc(隐含:include_type_name=false)。见官网:https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html#_typeless_apis_in_7_0

修改成:

代码语言:javascript复制
PUT /test2
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 0
  },
  "mappings": {
    "properties":{
      "id":{
        "type":"long"
      },
      "title":{
        "type":"text",
        "analyzer":"ik_max_word"
      },
      "content":{
        "type":"text",
        "analyzer":"ik_max_word"
      },
      "postdate":{
        "type":"date"
      },
      "url":{
        "type":"text"
      }
    }
  }
}

成功

代码语言:javascript复制
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "test2"
}

elasticsearch报错exceptions.RequestError(400, u’mapper_parsing_exception’, u’No handler field

在ElasticSearch创建index索引时,报错:elasticsearch.exceptions.RequestError: RequestError(400, u’mapper_parsing_exception’, u’No handler for type [string] declared on field [link]’),

原因:你用的是什么版本的ElasticSearch,5.X以上版本没有string类型了,换成了text和keyword作为字符串类型。

替换:

参考:https://blog.csdn.net/yanyf2016/article/details/103972806 https://www.cnblogs.com/feiquan/p/11888812.html https://blog.csdn.net/sinat_33718563/article/details/87177788

0 人点赞