{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Docs\/HybridSearchService.php",
"offset": 173,
"limit": 90
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Docs\/HybridSearchService.php",
"content": " \/** Enriches vector results with SQL data and applies filters. *\/\n private function enrichAndFilter(array $vectorResults, array $filters): array\n {\n $results = [];\n $minScore = $filters['min_score'] ?? 0.3;\n\n foreach ($vectorResults as $vr) {\n \/\/ Apply minimum score filter\n if ($vr['score'] < $minScore) {\n continue;\n }\n\n $chunkId = (int) ($vr['payload']['chunk_id'] ?? 0);\n if ($chunkId === 0) {\n continue;\n }\n\n \/\/ Get full chunk data from DB\n $chunk = $this->getChunkWithDocument($chunkId);\n if ($chunk === null) {\n continue;\n }\n\n \/\/ Apply entity filter\n if (isset($filters['entity_name'])) {\n $entities = $this->decodeJsonArray($chunk['entities'] ?? null);\n $found = false;\n foreach ($entities as $entity) {\n if (isset($entity['name']) && stripos($entity['name'], $filters['entity_name']) !== false) {\n $found = true;\n break;\n }\n }\n if (!$found) {\n continue;\n }\n }\n\n \/\/ Apply entity type filter\n if (isset($filters['entity_type'])) {\n $entities = $this->decodeJsonArray($chunk['entities'] ?? null);\n $found = false;\n foreach ($entities as $entity) {\n if (isset($entity['type']) && strtoupper($entity['type']) === strtoupper($filters['entity_type'])) {\n $found = true;\n break;\n }\n }\n if (!$found) {\n continue;\n }\n }\n\n \/\/ Apply keyword filter\n if (isset($filters['keyword'])) {\n $keywords = $this->decodeJsonArray($chunk['keywords'] ?? null);\n $found = false;\n foreach ($keywords as $kw) {\n if (stripos($kw, $filters['keyword']) !== false) {\n $found = true;\n break;\n }\n }\n if (!$found) {\n continue;\n }\n }\n\n $results[] = [\n 'chunk_id' => $chunkId,\n 'doc_id' => (int) $chunk['dokumentation_id'],\n 'path' => $chunk['doc_path'] ?? '',\n 'title' => $chunk['doc_title'] ?? '',\n 'content' => $chunk['content_clean'] ?? $chunk['content'] ?? '',\n 'heading_path' => $this->decodeJsonArray($chunk['heading_path'] ?? null),\n 'taxonomy' => $this->decodeJsonArray($chunk['taxonomy_path'] ?? null),\n 'entities' => $this->decodeJsonArray($chunk['entities'] ?? null),\n 'keywords' => $this->decodeJsonArray($chunk['keywords'] ?? null),\n 'score' => $vr['score'],\n 'relevance_score' => $vr['score'], \/\/ Will be adjusted in rerank\n ];\n }\n\n return $results;\n }\n\n \/** Re-ranks results based on combined semantic and structural relevance. *\/\n private function rerank(array $results, string $query): array\n {\n $queryWords = array_filter(preg_split('\/\\s+\/', strtolower($query)) ?: []);",
"numLines": 90,
"startLine": 173,
"totalLines": 366
}
}
}