zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Watir and Selenium
    WebDriver 原理 (zhuan)
    Junit4 如何实现并发测试用例,及 Selenium Grid2 与 Junit4 结合进行并发测试。
    Excel: 如何知道 A列中的条目是否在 B 列中
    WebDriver如何工作 (zhuan)
    复习 多线程
    Way To Get Xpath From IE (forward)
    Eclipse 常用快捷键
    如何引入(调用)一个 js文件
    Wireshark 常见 filter (转)
  • 原文地址:https://www.cnblogs.com/it-deepinmind/p/14521785.html
Copyright © 2011-2022 走看看