mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-05-27 19:25:58 +08:00
Refactor:improve dify retrieval logic (#15036)
### What problem does this PR solve? improve dify retrieval logic for o(n) io to o(1) ### Type of change - [x] Refactoring
This commit is contained in:
@ -294,9 +294,15 @@ async def retrieval(tenant_id):
|
||||
if ck["content_with_weight"]:
|
||||
ranks["chunks"].insert(0, ck)
|
||||
|
||||
doc_ids = list(set([c["doc_id"] for c in ranks["chunks"]]))
|
||||
docs = DocumentService.get_by_ids(doc_ids)
|
||||
doc_map = {doc.id: doc for doc in docs}
|
||||
|
||||
records = []
|
||||
for c in ranks["chunks"]:
|
||||
e, doc = DocumentService.get_by_id(c["doc_id"])
|
||||
doc = doc_map.get(c["doc_id"])
|
||||
if not doc:
|
||||
continue
|
||||
c.pop("vector", None)
|
||||
meta = getattr(doc, 'meta_fields', {})
|
||||
meta["doc_id"] = c["doc_id"]
|
||||
|
||||
Reference in New Issue
Block a user