elasticsearch data_error ai_generated true

IllegalArgumentException: 索引 [logs-2025] 中类型为 [keyword] 的字段 [user.name] 长度为 [32768],超过了最大允许长度 32766

IllegalArgumentException: Field [user.name] of type [keyword] in index [logs-2025] has a length of [32768] which exceeds the maximum allowed length of 32766

ID: elasticsearch/field-length-exceeds-keyword-limit

其他格式: JSON · Markdown 中文 · English
90%修复率
85%置信度
1证据数
2024-06-10首次发现

版本兼容性

版本状态引入弃用备注
7.10.0 active
8.10.0 active
8.13.0 active

根因分析

文档中的关键字字段值超过了 32766 字节的限制,导致索引被拒绝。

English

A document contains a keyword field value that exceeds the 32766-byte limit, causing indexing rejection.

generic

官方文档

https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html#keyword-field-type-limits

解决方案

  1. 将字段类型更改为 `text` 并添加 `keyword` 子字段用于精确匹配:`PUT my_index/_mapping { "properties": { "user.name": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } } } }`。
  2. 在应用程序级别截断字段值,确保其小于 32766 字节后再索引。
  3. 使用带有 `ignore_above` 设置的 `keyword` 字段,设置值小于 32766 以跳过索引长值。

无效尝试

常见但无效的做法:

  1. 80% 失败

    `ignore_above` truncates the field, it does not increase the keyword length limit.

  2. 90% 失败

    Removing `ignore_above` does not change the hard byte limit for keyword fields.

  3. 85% 失败

    Reindexing without addressing the field type will still reject large values.