繁体   English   中英

Elasticsearch 6创建新字段需要数据类型,但“在6.x中创建的索引仅允许每个索引使用单一类型”

[英]Elasticsearch 6 create new field requires data type but “Indices created in 6.x only allow a single-type per index”

在Elasticsearch 6.6.2中创建新字段会出现以下错误:

{
   "error": {
      "root_cause": [
         {
            "type": "action_request_validation_exception",
            "reason": "Validation Failed: 1: mapping type is missing;"
         }
      ],
      "type": "action_request_validation_exception",
      "reason": "Validation Failed: 1: mapping type is missing;"
   },
   "status": 400
}

要求:

curl --request PUT http://10.1.3.81:9200/netswitch_message/_mapping -H "Content-Type: application/json" -d \
'{
   "properties": {
     "amount": {"type": "integer"}
   }
 }' 

不管我使用哪种数据类型,都会产生错误。 索引已经具有整数,文本/关键字,文本和日期类型。

curl --request PUT http://10.1.3.81:9200/netswitch_message/_mapping -H "Content-Type: application/json" -d "{\"properties\": {\"amount\": {\"type\": \"integer\"}}}"
curl --request PUT http://10.1.3.81:9200/netswitch_message/_mapping -H "Content-Type: application/json" -d "{\"properties\": {\"amount\": {\"type\": \"text\"}}}"
curl --request PUT http://10.1.3.81:9200/netswitch_message/_mapping/data -H "Content-Type: application/json" -d "{\"properties\": {\"amount\": {}}}"
curl --request PUT http://10.1.3.81:9200/netswitch_message/_mapping -H "Content-Type: application/json" -d "{\"properties\": {\"amount\": {}}}

Expected to create a new field
Actually got syntax error:
    {"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: mapping type is missing;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: mapping type is missing;"},"status":400}

没错,6.x将您限制为单个_type ,但是您仍然需要提供该类型的名称(在7.x中,它默认为_doc )。

更改您的映射以指定_type ,如下所示将其设置为“ my-type”:

curl --request PUT http://10.1.3.81:9200/netswitch_message/_mapping/my-type -H "Content-Type: application/json" -d \
'{
    "properties": {
       "amount": {"type": "integer"}
    }
 }' 

请参阅: https//www.elastic.co/guide/zh-CN/elasticsearch/reference/6.6/indices-put-mapping.html#indices-put-mapping

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM