We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents dc1a326 + c89ad98 commit a174e0aCopy full SHA for a174e0a
1 file changed
ragflows/ragflowdb.py
@@ -48,9 +48,14 @@ def get_doc_item(doc_id):
48
return results[0] if results else None
49
50
@timeutils.monitor
51
-def get_doc_item_by_name(doc_id):
+def get_doc_item_by_name(name):
52
db = get_db()
53
- sql = f"select id,name,progress from document where name = '{doc_id}'"
+ kb_id = configs.DIFY_DOC_KB_ID
54
+ if kb_id:
55
+ # 这里同时查询kb_id和name,如果document表中的数据量很大,需要增加kb_id和name的组合索引:CREATE INDEX document_kb_id_name ON document(kb_id, name);
56
+ sql = f"select id,name,progress from document where kb_id = '{kb_id}' and name = '{name}'"
57
+ else:
58
+ sql = f"select id,name,progress from document where name = '{name}'"
59
results = db.query_list(sql)
60
61
0 commit comments