What Can I Do If Data Fails to Be Written Because the Type of the Data to Be Written Is Different from That of the Existing Data?
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 -XGET --tlsv1.2 --negotiate -k -u : "https://ip:httpport/test_index/test_type2/id111?pretty" -H 'Content-Type: application/json' -d' { "gcsj": "2018-10-13 10:20:05","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 is in the https://ip:httpport/test_index/test_type2/id111 format. There are three fields except the Elasticsearch node information, including 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 is added to Elasticsearch 6.X. This log information indicates that if the data is written, the type of the index data is different from that of the existing index data. As a result, the index writing fails.
You can run required commands to check the mapping of the index, confirm the existing index type name, and check whether the type of the new data is the same as that of the existing type.
curl -XGET --tlsv1.2 --negotiate -k -u : "https://ip:httpport/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 } } } } } } } }
Solution
When importing data, ensure that the data type in one index is the same.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot