too_many_clauses: too_many_clauses: maxClauseCount is set to 1024 (query contains too many clauses)
Elasticsearch의미
쿼리가 허용된 최대 Lucene clause 수를 초과했다. ES 8.x에서는 이 한도가 고정이 아니며 노드의 heap 크기와 검색 스레드 수로부터 자동 계산된다(heap이 작은 노드에서는 1024까지 내려갈 수 있다). 오류 메시지에 현재 값이 표시된다. 매우 큰 bool 쿼리와 많은 term으로 확장되는 쿼리가 원인이 된다.
원인
프로그램으로 생성한 수천 개의 should/must clause를 가진 bool 쿼리, 많은 term으로 확장되는 wildcard/prefix/fuzzy/query_string 쿼리, 깊게 중첩된 bool 구조. 참고: terms 쿼리(단일 필드의 값 목록)는 이 한도의 대상이 아니며, 그 상한은 index.max_terms_count(기본 65,536)이다.
해결 방법
쿼리를 단순화한다: 단일 필드에 대한 많은 term clause를 하나의 terms 쿼리로 변환한다(큰 목록은 terms lookup). wildcard/prefix 대신 더 구체적인 쿼리 타입이나 index_prefixes/keyword 필드를 사용한다. ES 8.x에서 indices.query.bool.max_clause_count 설정은 deprecated이며 무시된다. 한도를 높이는 방법은 노드 heap을 늘리는 것이다. 쿼리 생성 로직을 검토한다.
같은 데이터베이스의 다른 항목
- strict_dynamic_mapping_exceptionstrict_dynamic_mapping_exception: mapping set to strict, dynamic introduction of [...] within [...] is not allowed
- 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
- search_phase_execution_exceptionsearch_phase_execution_exception: all shards failed / Failed to execute phase [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)