KevinHuSh
commited on
Commit
·
ef1c080
1
Parent(s):
d78590b
Knowledge base search is case sensitive (#797)
Browse files### What problem does this PR solve?
#793
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
api/db/services/document_service.py
CHANGED
@@ -16,6 +16,7 @@
|
|
16 |
import random
|
17 |
from datetime import datetime
|
18 |
from elasticsearch_dsl import Q
|
|
|
19 |
|
20 |
from api.settings import stat_logger
|
21 |
from api.utils import current_timestamp, get_format_time
|
@@ -40,8 +41,9 @@ class DocumentService(CommonService):
|
|
40 |
orderby, desc, keywords):
|
41 |
if keywords:
|
42 |
docs = cls.model.select().where(
|
43 |
-
cls.model.kb_id == kb_id,
|
44 |
-
cls.model.name.
|
|
|
45 |
else:
|
46 |
docs = cls.model.select().where(cls.model.kb_id == kb_id)
|
47 |
count = docs.count()
|
|
|
16 |
import random
|
17 |
from datetime import datetime
|
18 |
from elasticsearch_dsl import Q
|
19 |
+
from peewee import fn
|
20 |
|
21 |
from api.settings import stat_logger
|
22 |
from api.utils import current_timestamp, get_format_time
|
|
|
41 |
orderby, desc, keywords):
|
42 |
if keywords:
|
43 |
docs = cls.model.select().where(
|
44 |
+
(cls.model.kb_id == kb_id),
|
45 |
+
(fn.LOWER(cls.model.name).contains(keywords.lower()))
|
46 |
+
)
|
47 |
else:
|
48 |
docs = cls.model.select().where(cls.model.kb_id == kb_id)
|
49 |
count = docs.count()
|