RAG Collections
Verwaltung der Qdrant-Collections für RAG-Suche in Chat und Content Studio.
| Datenbank | ki_dev |
|---|---|
| Tabelle | rag_collections |
| Repository | /src/Infrastructure/Persistence/CollectionRepository.php |
| Qdrant-API | http://localhost:6333 |
Zweck
Die Tabelle rag_collections synchronisiert Metadaten von Qdrant-Collections mit der Anwendung:
- Collection-Auswahl in Chat und Content Studio
- Validierung der Embedding-Dimensionen
- Anzeige von Collection-Statistiken
- Steuerung der Suchbarkeit (is_searchable)
Schema
| Spalte | Typ | Default | Beschreibung |
|---|---|---|---|
| id | INT AUTO_INCREMENT | - | Primary Key |
| collection_id | VARCHAR(100) UNIQUE | - | Qdrant Collection-Name |
| display_name | VARCHAR(100) | - | Anzeigename in UI |
| description | TEXT | NULL | Beschreibung |
| vector_size | INT | NULL | Embedding-Dimension (z.B. 1024) |
| distance_metric | VARCHAR(20) | NULL | Cosine, Euclidean, Dot |
| points_count | INT | 0 | Anzahl Vektoren |
| embedding_model | VARCHAR(100) | NULL | z.B. mxbai-embed-large |
| chunk_size | INT | NULL | Chunk-Größe in Zeichen |
| chunk_overlap | INT | NULL | Chunk-Überlappung |
| source_type | ENUM | 'manual' | nextcloud, mail, manual, system |
| source_path | VARCHAR(500) | NULL | Quellpfad (z.B. Nextcloud-Ordner) |
| is_active | TINYINT(1) | 1 | Collection aktiv |
| is_searchable | TINYINT(1) | 1 | In Suche verfügbar |
| sort_order | INT | 0 | Sortierung in UI |
| last_synced_at | DATETIME | NULL | Letzte Synchronisation |
| created_at | DATETIME | CURRENT_TIMESTAMP | Erstellungszeitpunkt |
| updated_at | DATETIME | CURRENT_TIMESTAMP | Letzte Änderung |
Aktuelle Collections (Qdrant)
Collections werden in /var/www/scripts/pipeline/config.py definiert:
| collection_id | display_name | vector_size | Zweck |
|---|---|---|---|
| documents | Dokumente | 1024 | Nextcloud-Dokumente (PDF, DOCX, etc.) |
| E-Mails | 1024 | E-Mail-Archiv | |
| entities | Entitäten | 1024 | Extrahierte Entitäten mit Embeddings |
Repository-Methoden
// Alle suchbaren Collections abrufen
$collections = $collectionRepository->getSearchable();
// Collection-Details
$collection = $collectionRepository->findById('documents');
// Statistiken aktualisieren (Qdrant-Sync)
$collectionRepository->syncFromQdrant();
Validierung
Bei Multi-Collection-Suche müssen alle Collections die gleiche Embedding-Dimension haben:
$validator = new CollectionValidator($collectionRepository);
$result = $validator->validateSelection(['documents', 'entities']);
if (!$result->isValid()) {
throw new \InvalidArgumentException($result->getError());
}
UI-Integration
Collections werden als Checkbox-Gruppe in Chat und Content Studio angezeigt:
<?php
$selected = ['documents'];
$variant = 'checkbox';
include __DIR__ . '/../partials/form/collections-select.php';
?>
Siehe auch
Änderungshistorie
| Datum | Änderung |
|---|---|
| 2025-12-31 | Collections korrigiert: entities hinzugefügt, dokumentation entfernt (existiert nicht in Qdrant) |
| 2025-12-21 | Initial erstellt |