Notes
-
Arrays: In Elasticsearch, all fields support arrays natively. In ClickHouse, arrays must be explicitly defined (e.g.,
Array(String)), with the advantage specific positions can be accessed and queried e.g.an_array[1]. -
Multi-fields: Elasticsearch allows indexing the same field multiple ways (e.g., both
textandkeyword). In ClickHouse, this pattern must be modeled using separate columns or views. -
Map and JSON Types - In ClickHouse, the
Maptype is commonly used to model dynamic key-value structures such asresourceAttributesandlogAttributes. This type enables flexible schema-less ingestion by allowing arbitrary keys to be added at runtime — similar in spirit to JSON objects in Elasticsearch. However, there are important limitations to consider:- Uniform value types: ClickHouse
Mapcolumns must have a consistent value type (e.g.,Map(String, String)). Mixed-type values aren’t supported without coercion. - Performance cost: accessing any key in a
Maprequires loading the entire map into memory, which can be suboptimal for performance. - No subcolumns: unlike JSON, keys in a
Maparen’t represented as true subcolumns, which limits ClickHouse’s ability to index, compress, and query efficiently.
Mapin favor of ClickHouse’s enhancedJSONtype. TheJSONtype addresses many of the shortcomings ofMap:- True columnar storage: each JSON path is stored as a subcolumn, allowing efficient compression, filtering, and vectorized query execution.
- Mixed-type support: different data types (e.g., integers, strings, arrays) can coexist under the same path without coercion or type unification.
-
File system scalability: internal limits on dynamic keys (
max_dynamic_paths) and types (max_dynamic_types) prevent an explosion of column files on disk, even with high cardinality key sets. -
Dense storage: nulls and missing values are stored sparsely to avoid unnecessary overhead.
The
JSONtype is especially well-suited for observability workloads, offering the flexibility of schemaless ingestion with the performance and scalability of native ClickHouse types — making it an ideal replacement forMapin dynamic attribute fields. For further details on the JSON type we recommend the JSON guide and “How we built a new powerful JSON data type for ClickHouse”.
- Uniform value types: ClickHouse