Got it

Data Writing Failure Due to the Type of Data to Be Written Was Different from That of the Existing Data in Elasticsearch

338 0 1 0 0

Hello all, 

this case mainly talks about "Data Writing Failure Due to the Type of Data to Be Written Was Different from That of the Existing Data"


Applicable Version

6.5.x

Context and Symptom

The client failed to write data, and the error message "illegal_argument_exception, final mapping would have more than 1 type" was displayed.

 curl -XPOST   'http://xxx.xxx.xxx.34:24100/test_index/test_type2/id111?pretty' -H 'Content-Type: application/json' -d' { "gcsj": "2018-10-13 02:20","bh": "2fdc8d48-45d5-46c3-8550-de4400a87c1c"}'
{
 "error" : {
   "root_cause" : [
     {
       "type" : "illegal_argument_exception",
       "reason" : "Rejecting mapping update to [test_index] as the final mapping would have more than 1 type: [test_type1, test_type2]"
     }
   ],
   "type" : "illegal_argument_exception",
   "reason" : "Rejecting mapping update to [test_index] as the final mapping would have more than 1 type: [test_type1, test_type2]"
 },
 "status" : 400
}

Cause Analysis

The data to be written was in the following format: http://xxx.xxx.xxx.34:24100/test_index/test_type2/id111. There were three fields except the Elasticsearch node information: index (for example, test_index), type (for example, test_type), and ID (for example, id111). The kernel constraint that data in an index can have only one data type was added to Elasticsearch 6.X. This log information indicated that if the data was written to, the type of the index data was different from that of the existing index data. As a result, the index writing failed.

You can run the following command to check the mapping of the index, confirm the existing index type name, and check whether the type of the new data was the same as the existing type.

  curl -PUT  "http://xxx.xxx.xxx.34:24100/test_index/_mapping?pretty"
{
 "test_index" : {
   "mappings" : {
     "test_type1" : {
       "properties" : {
         "date" : {
           "type" : "date",
           "format" : "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis"
         },
         "text" : {
           "type" : "text",
           "fields" : {
             "keyword" : {
               "type" : "keyword",
               "ignore_above" : 256
             }
           }
         }
       }
     }
   }
 }
}

The preceding was an example in common mode. In security mode, run the following command:

curl -XGET --negotiate -k -u : "https://IP:HTTPPORT/test_index/_mapping?pretty"

Solution

  1. When importing data, ensure that the data type in one index is the same.

Any solutions will be appreciated!

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.