PUT student { "mappings" : { "properties" : { "name" : { "type" : "keyword" } } }, "settings" : { "index" : { "number_of_shards" : 1 } } }
插入简单数据测试
POST student/_doc/1 { "name": "1111" }
成功插入。
POST student/_doc/0123456789 { "name": "2222" }
成功插入。
插入 _id 长度为 230 字节的数据
POST student/_doc/0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789 { "name": "3333" }
成功。
插入 _id 长度为 648 字节的数据(会失败)
POST student/_doc/0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789 { "name": "4444" }
报错如下:
{ "error": { "root_cause": [ { "type": "action_request_validation_exception", "reason": "Validation Failed: 1: id is too long, must be no longer than 512 bytes but was: 648;" } ], "type": "action_request_validation_exception", "reason": "Validation Failed: 1: id is too long, must be no longer than 512 bytes but was: 648;" }, "status": 400 }
插入 _id 是 270 个中文字符的数据
大部分中文字符,在 UTF-8 中用3个字节存储。270个中文,510 字节。
POST student/_doc/零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九 { "name": "5555" }
成功。
插入 _id 是 271 个中文字符的数据(会失败)
271 个中文,对应 513 个字节。
POST student/_doc/零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零一二三四五六七八九零 { "name": "5555" }
报错信息如下:
{ "error": { "root_cause": [ { "type": "action_request_validation_exception", "reason": "Validation Failed: 1: id is too long, must be no longer than 512 bytes but was: 513;" } ], "type": "action_request_validation_exception", "reason": "Validation Failed: 1: id is too long, must be no longer than 512 bytes but was: 513;" }, "status": 400 }
( 本文完 )
转载于:https://www.letianbiji.com/elasticsearch/es7-doc-id-limit.html