too_many_clauses: too_many_clauses: maxClauseCount is set to 1024 (query contains too many clauses)(查询包含的子句过多)
Elasticsearch含义
查询超出了允许的 Lucene 子句最大数量。在 ES 8.x 中该限制不是固定的;它根据节点堆大小和搜索线程数自动计算(在小堆节点上可能降至 1024),错误消息会显示当前值。非常大的 bool 查询以及展开为大量词项的查询会触发该错误。
原因
通过程序生成的带有成千上万个 should/must 子句的 bool 查询;展开为大量词项的 wildcard/prefix/fuzzy/query_string 查询;深度嵌套的 bool 结构。注意:terms 查询(单个字段上的值列表)不受此限制;其上限为 index.max_terms_count(默认 65,536)。
解决方法
简化查询:将单个字段上的大量 term 子句合并为一个 terms 查询(大型列表使用 terms lookup)。使用更具体的查询类型,或用 index_prefixes/keyword 字段代替 wildcard/prefix。在 ES 8.x 中 indices.query.bool.max_clause_count 设置已弃用并被忽略;提高该限制的方法是增大节点堆。检查查询生成逻辑。
同一数据库的其他条目
- strict_dynamic_mapping_exceptionstrict_dynamic_mapping_exception: mapping set to strict, dynamic introduction of [...] within [...] is not allowed(mapping 设为 strict,不允许动态添加字段)
- illegal_argument_exception_fielddataillegal_argument_exception: Fielddata is disabled on text fields by default. Set fielddata=true on [your_field] in order to load fielddata in memory(text 字段默认禁用 fielddata)
- search_phase_execution_exceptionsearch_phase_execution_exception: all shards failed / Failed to execute phase [query](所有分片均失败 / 执行 [query] 阶段失败)
- version_conflict_engine_exceptionversion_conflict_engine_exception: [_doc][id]: version conflict, current version [x] is different than the one provided [y] (HTTP 409)(版本冲突,当前版本与提供的版本不同)
- document_missing_exceptiondocument_missing_exception: [_doc][id]: document missing(文档不存在)
- index_not_found_exceptionindex_not_found_exception: no such index [index_name] (HTTP 404)(索引不存在)
- resource_already_exists_exceptionresource_already_exists_exception: index [index_name/uuid] already exists (HTTP 400)(索引已存在)