feat: knowledge extend search to file content

Enhance knowledge search to match not only file titles but also
the underlying file content.

This improves search coverage and allows users to locate entries
based on full content, not just metadata.

Note:
Future improvement could include diacritic-insensitive search
(e.g. PostgreSQL unaccent) to better support languages such as Greek.
This commit is contained in:
Athanasios Oikonomou 2026-05-01 18:57:21 +03:00 committed by Athanasios Oikonomou
parent 4e2240aada
commit d570c6f518

View file

@ -467,7 +467,11 @@ class KnowledgeTable:
if filter:
query_key = filter.get('query')
if query_key:
stmt = stmt.filter(or_(File.filename.ilike(f'%{query_key}%')))
if db.bind.dialect.name == 'sqlite':
stmt_content = File.data['content'].ilike(f'%{query_key}%')
else:
stmt_content = File.data.op('->>')('content').ilike(f'%{query_key}%')
stmt = stmt.filter(or_(File.filename.ilike(f'%{query_key}%'), stmt_content))
view_option = filter.get('view_option')
if view_option == 'created':