• Elasticsearch 7 : 文档 _id 的长度限制


    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

  • 相关阅读:
    【leetcode】11. 盛最多水的容器
    【leetcode】8. 字符串转换整数 (atoi)
    【leetcode】6. Z 字形变换
    【leetcode】5. 最长回文子串
    【leetcode】LCP 19. 秋叶收藏集
    删除第一个节点问题
    问一个大学学习计算机这门专业的问题
    Struts文件上传页面上传后显示“连接已重置”
    2013-12-6 思杨没吃饱 饿醒了
    2013-12-7 snoopy乐园中的思杨
  • 原文地址:https://www.cnblogs.com/it-deepinmind/p/14521785.html
Copyright © 2020-2023  润新知