Knowledge base search is case sensitive (#797)

### What problem does this PR solve?
#793 
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
KevinHuSh 2024-05-16 09:00:12 +08:00 committed by GitHub
parent 10e83f26dc
commit 1c4e92ed35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,6 +16,7 @@
import random import random
from datetime import datetime from datetime import datetime
from elasticsearch_dsl import Q from elasticsearch_dsl import Q
from peewee import fn
from api.settings import stat_logger from api.settings import stat_logger
from api.utils import current_timestamp, get_format_time from api.utils import current_timestamp, get_format_time
@ -40,8 +41,9 @@ class DocumentService(CommonService):
orderby, desc, keywords): orderby, desc, keywords):
if keywords: if keywords:
docs = cls.model.select().where( docs = cls.model.select().where(
cls.model.kb_id == kb_id, (cls.model.kb_id == kb_id),
cls.model.name.like(f"%%{keywords}%%")) (fn.LOWER(cls.model.name).contains(keywords.lower()))
)
else: else:
docs = cls.model.select().where(cls.model.kb_id == kb_id) docs = cls.model.select().where(cls.model.kb_id == kb_id)
count = docs.count() count = docs.count()