diff --git a/src/store.py b/src/store.py index 84e9256..925fa34 100644 --- a/src/store.py +++ b/src/store.py @@ -6,6 +6,7 @@ Keine externen Abhängigkeiten außer sqlite3 (stdlib). import json import sqlite3 import os +import re from pathlib import Path from typing import List, Optional, Dict, Any from uuid import UUID @@ -158,7 +159,12 @@ class EngramStore: def search_text(self, query: str, limit: int = 10) -> List[Engram]: """Full-Text-Suche über Engramm-Inhalt via SQLite FTS5 (OR-Verknüpfung).""" # FTS5-Syntax: Wörter mit OR verbinden für bessere Ergebnisse - words = [w.strip() for w in query.replace("'", "''").split() if w.strip()] + words = [] + for word in query.split(): + # Nur alphanumerische Zeichen als FTS5-Tokens akzeptieren + clean_word = re.sub(r'[^a-zA-Z0-9]+', '', word) + if clean_word: + words.append(clean_word) safe_query = " OR ".join(words) if len(words) > 1 else (words[0] if words else "*") sql = """ SELECT e.* FROM engrams e