Document Pipeline
Automatischer Import und Verarbeitung von Dokumenten aus Nextcloud.
| Quelle | Nextcloud /Documents (lokal) |
| Formate | PDF, PPTX, DOCX, MD, TXT |
| Trigger | Polling + Event-basiert |
| Sprache | Python 3.13 |
Pipeline-Schritte
1. DETECT → Neue/geänderte Dateien erkennen
2. EXTRACT → Text extrahieren (OCR, Vision)
3. CHUNK → Semantisches Chunking
4. ENRICH → Metadaten anreichern
5. STORE → In MariaDB speichern
6. EMBED → Vektoren erzeugen
7. INDEX → In Qdrant speichern
8. ANALYZE → Semantische Analyse
Text-Extraktion
| Format | Tool | Features |
| PDF | PyMuPDF | OCR via Tesseract |
| PPTX | python-pptx | Slides + Speaker Notes |
| DOCX | python-docx | Text-Extraktion |
| MD/TXT | direkt | UTF-8 |
Bild-Handling
Bilder in Dokumenten werden via Vision-API beschrieben und als Text-Chunk gespeichert.
Chunking
| Methode | Semantisch + Hierarchisch |
| Größe | Intelligent (kontextabhängig) |
| Overlap | ~10% |
| Hierarchie | Dokument → Kapitel → Abschnitt |
Chunk-Metadaten
{
"document_id": 123,
"chunk_index": 0,
"heading_path": ["Kapitel 1", "Abschnitt 1.2"],
"source_folder": "/Documents/Therapie",
"entities": ["Carl Rogers"],
"taxonomy_terms": ["Methoden"]
}
Queue-System
| Technologie | MariaDB Table (pipeline_queue) |
| Retry | Max 3 Versuche, exponential backoff |
| Logging | MariaDB Table (pipeline_log) |
Pipeline-Scripts
/opt/scripts/pipeline/
├── pipeline.py → Haupt-Orchestrierung
├── detect.py → Datei-Monitoring
├── extract.py → Text-Extraktion
├── chunk.py → Semantisches Chunking
├── embed.py → Embedding-Erzeugung
├── analyze.py → Semantische Analyse
├── db.py → Datenbank-Operationen
├── config.py → Konfiguration
├── run.sh → Ausführungs-Wrapper
└── venv/ → Python Virtual Environment
Ausführung
cd /opt/scripts/pipeline
# Neue Dokumente scannen
./run.sh scan
# Queue verarbeiten
./run.sh process
# Pending Embeddings
./run.sh embed
# Volle Pipeline
./run.sh all
# Einzelne Datei
./run.sh file /pfad/zur/datei.pdf
# Status anzeigen
./run.sh status