symfony/ai-click-house-store
ClickHouse vector store integration for Symfony AI Store. Store and query embeddings in ClickHouse using distance functions and ANN/vector indexes for fast similarity search. Links to ClickHouse docs plus Symfony AI contributing and issue tracker.
StoreInterface, providing a clean abstraction for vector storage/retrieval in ClickHouse. This aligns well with Laravel/Symfony applications already using Symfony AI for embeddings, enabling plug-and-play replacement of existing stores (e.g., DoctrineStore, RedisStore).WHERE metadata.category = 'tech'), enabling multi-modal search without post-processing. This is a unique advantage over standalone vector databases like Pinecone or Weaviate.Potential Gaps:
SELECT ... ASYNC) aren’t exposed by this bridge.SELECT version()). ANN indexes (e.g., HNSW) must be explicitly configured.StoreInterface changes in newer versions).clickhouse/client or HTTP driver).Array(Float32) with an ANN index (e.g., TYPE ann(1024) GRANULARITY=3). Example:
CREATE TABLE vectors (
id UInt64,
embedding Array(Float32),
metadata String,
INDEX ann_index embedding TYPE ann(1024) GRANULARITY=3
) ENGINE = MergeTree();
bind()).findAll() to serialize vectors (e.g., to JSON).INSERT INTO ... VALUES or the HTTP API.Array(Float32)).Key Dependencies:
| Dependency | Version Check | Risk Level | Notes |
|---|---|---|---|
symfony/ai |
^0.8.0 | High | Breaking changes possible in minor updates. |
clickhouse/client |
^1.0 | Low | Fallback to HTTP driver if needed. |
| ClickHouse | v22.8+ | Critical | Vector/ANN features required. |
| PHP | 8.1+ | Medium | Symfony AI’s minimum requirement. |
| Risk Area | Description | Mitigation Strategy |
|---|---|---|
| Schema Mismatch | Vector dimensionality or ANN index misconfiguration → queries fail or return incorrect results. | Validate schema with a test dataset; use DESCRIBE TABLE to verify structure. |
| Performance Degradation | Poor ANN index settings (e.g., GRANULARITY) → slow similarity searches. |
Benchmark with system.asynchronous_metrics; adjust GRANULARITY/GRAPH_SIZE based on query patterns. |
| Symfony AI Version | Incompatible StoreInterface changes in newer Symfony AI versions. |
Pin to a stable version (e.g., symfony/ai:0.8.0) and test against minor updates. |
| ClickHouse Downtime | No built-in retry logic for transient failures (e.g., network issues). | Implement exponential backoff in Laravel’s HTTP client or use a circuit breaker pattern. |
| Vector Size Limits | ClickHouse’s Array(Float32) has a 65K-element limit (may exceed for high-dimensional data). |
Use compression (e.g., Float16) or split vectors into multiple columns if needed. |
| Concurrency Issues | High write throughput may overwhelm ClickHouse’s merge tree engine. | Monitor system.merge_tree metrics; consider batching writes or using ReplicatedMergeTree. |
Critical Questions:
Array(Float32) limit (65K)?WHERE category = 'tech')? If so, ensure ClickHouse tables include these columns.symfony/ai-doctrine-store replacements).WHERE embedding_date > '2023-01-01').StoreInterface; not compatible with raw Laravel or other PHP frameworks.Compatibility Matrix:
| Component | Compatible Versions | Notes |
|---|---|---|
| Laravel | 10.x+ (Symfony components) | Use symfony/ai via Composer. |
| Symfony AI | ^0.8.0 | Test against minor updates. |
| ClickHouse | v22.8+ | Vector/ANN features required. |
| PHP | 8.1+ | Symfony AI’s minimum requirement. |
| Doctrine | Optional (for hybrid ORM setups) | Not required but may conflict with schema. |
Assessment Phase:
symfony/ai-doctrine-store).SELECT version()) and vector support.embedding Array(Float32), ANN index).Setup ClickHouse:
clickhouse-local).CREATE TABLE vectors (
id UInt64,
embedding Array(Float32),
metadata String,
INDEX ann_index embedding TYPE ann(1024) GRANULARITY=3
) ENGINE = MergeTree() ORDER BY id;
// config/clickhouse.php
'connections' => [
'default' => [
'driver' => 'http', // or 'native'
'host' => env('CLICKHOUSE_HOST', 'localhost'),
'port' => env('CLICKHOUSE_PORT', 8123),
'database' => 'ai_vectors',
'username' => env('CLICKHOUSE_USER', 'default'),
'password' =>
How can I help you explore Laravel packages today?